--
Jim Rech
Excel MVP
If the cells are hidden by manually hiding rows/columns, you'll need a custom worksheet function. Here's one for you:
Function SUMVISIBLE(ParamArray number())
' Returns the sum of visible cells in a range
Dim Cell As Range, i As Long
Application.Volatile
SUMVISIBLE = 0
For i = 0 To UBound(number)
If Not IsError(number(i)) Then
If TypeName(number(i)) = "Range" Then
Set number(i) = Intersect(number(i).Parent.UsedRange, number(i))
For Each Cell In number(i)
If IsError(Cell) Then SUMVISIBLE = Cell: Exit Function
If Not Cell.EntireRow.Hidden And Not Cell.EntireColumn.Hidden Then _
SUMVISIBLE = SUMVISIBLE + Evaluate(Application.Sum(Cell))
Next Cell
Else
SUMVISIBLE = SUMVISIBLE + Evaluate(Application.Sum(number(i)))
End If
End If
Next i
End Function
Just copy this function to a standard VBA module. Then, you can use it in your formulas. It works just like the SUM function, and supports multiple arguments.
John Walkenbach
For Excel tips, macros, & downloads...
http://j-walk.com/ss
"Wilson" <jwi...@wickes.com> wrote in message news:eBqporUlBHA.2156@tkmsftngp05...
> Who Coded Thi§ Me§§?
>
>
-John
"John Walkenbach" <jo...@j-walk.com> wrote in message news:eYstK1UlBHA.1976@tkmsftngp05...
> Who Coded Thiง Meงง?
>
>
Function SumVis(Rg As Range) As Double
Dim Cell As Range
Application.Volatile
For Each Cell In Rg
If Cell.EntireRow.Hidden = False Then
''If only rows can be hidden remove this If
If Cell.EntireColumn.Hidden = False Then
SumVis = SumVis + Cell.Value
End If ''and this Enf If
End If
Next
End Function
Jim
For example: If you have 14.70833, we want to format the cell so that it
will read 14'-8.5" or 14'-8 1/2" (including the feet and inch symbols). We
also need to be able to use this number in formulas, so it has to remain
accessible to Excel as a numeral.
Do you have any suggestions?