I heart Excel
Board Regular
- Joined
- Feb 28, 2011
- Messages
- 66
Hello,
Hope everyone had a nice a weekend!!
I am trying to sum only the visible cells on my spreadsheet.
I have had a look and tried two ways -
Way 1 =
Function VisTotal(Rg as Range)
dim x, tot
Application.Volatile
tot=0
For each x in Rg
if c.visible then tot=tot+x
Next
End Function
in Worksheet -
=VisTotal(E54,E49,E47,E39,E34,E32,E24,E19,E17)
Way 2 =
<CODE>
Function Sum_Visible_Cells(Cells_To_Sum As Object) Application.Volatile For Each cell In Cells_To_Sum If cell.Rows.Hidden = False Then If cell.Columns.Hidden = False Then total = total + cell.Value End If End If Next Sum_Visible_Cells = total End Function </PRE>
In worksheet - =Sum_Visible_Cells(E54,E49,E47,E39,E34,E32,E24,E19,E17)
On both I get a #NAME? error?! And I can't figure out why.
thanks
</CODE>
</PRE>
Hope everyone had a nice a weekend!!
I am trying to sum only the visible cells on my spreadsheet.
I have had a look and tried two ways -
Way 1 =
Function VisTotal(Rg as Range)
dim x, tot
Application.Volatile
tot=0
For each x in Rg
if c.visible then tot=tot+x
Next
End Function
in Worksheet -
=VisTotal(E54,E49,E47,E39,E34,E32,E24,E19,E17)
Way 2 =
<CODE>
Function Sum_Visible_Cells(Cells_To_Sum As Object) Application.Volatile For Each cell In Cells_To_Sum If cell.Rows.Hidden = False Then If cell.Columns.Hidden = False Then total = total + cell.Value End If End If Next Sum_Visible_Cells = total End Function </PRE>
In worksheet - =Sum_Visible_Cells(E54,E49,E47,E39,E34,E32,E24,E19,E17)
On both I get a #NAME? error?! And I can't figure out why.
thanks
</CODE>
</PRE>