View Single Post
  #7   Report Post  
Posted to microsoft.public.excel.worksheet.functions
mcescher mcescher is offline
external usenet poster
 
Posts: 24
Default Subtoal excluding hidden columns

On Nov 25, 8:55*am, Trevor wrote:
Does anyone how I can sum many columns within a row but exclude hidden colums
from the calculation?
*The subtotal(109,"range") works for rows but not columns

Thank you!


Here's a sum and a count function. Hope it helps. Chris M.

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

Function Count_Visible_Cells(Cells_To_Count As Object)
Application.Volatile
For Each cell In Cells_To_Count
If cell.Rows.Hidden = False Then
If cell.Columns.Hidden = False Then
rowcnt = rowcnt + 1
End If
End If
Next
Count_Visible_Cells = rowcnt
End Function