You could use a User Defined Function like:
Option Explicit
Function sumVisible(rng As Range) As Double
Application.Volatile
Dim mySum As Double
Dim myCell As Range
mySum = 0
For Each myCell In rng.Cells
With myCell
If .EntireRow.Hidden _
Or .EntireColumn.Hidden _
Or Application.IsNumber(.Value) = False Then
'do nothing
Else
mySum = mySum + .Value
End If
End With
Next myCell
sumVisible = mySum
End Function
If you're new to macros, you may want to read David McRitchie's intro at:
http://www.mvps.org/dmcritchie/excel/getstarted.htm
=======
Short course:
Open your workbook.
Hit alt-f11 to get to the VBE (where macros/UDF's live)
hit ctrl-R to view the project explorer
Find your workbook.
should look like: VBAProject (yourfilename.xls)
right click on the project name
Insert, then Module
You should see the code window pop up on the right hand side
Paste the code in there.
Now go back to excel.
Type =sumVisible(A1:b9)
But be a little careful with this kind of function. It updates each time excel
recalculates. So if you hide some rows/columns and excel doesn't recalc, then
your results may be off--until the next recalc.
You can force a recalc by:
tools|options|calculate tab|click the "Calc now" button
(or just hit F9)