Summing visible cells only

Tim Grollman

Board Regular
Joined
Feb 24, 2002
Messages
129
I want to sum just the cells I can see when I have a filter on. Do I need to have a column which contains a 1 when the the row is visible and a zero otherwise, and use SUMPRODUCT or is there an easier way? Thanks
 

Excel Facts

Does the VLOOKUP table have to be sorted?
No! when you are using an exact match, the VLOOKUP table can be in any order. Best-selling items at the top is actually the best.
Hi,

Try this UDF...

Function SumVisible(RefRange As Range)
Dim UsedCell As Range, temp As Double
Application.Volatile

For Each UsedCell In RefRange
If Not UsedCell.EntireRow.Hidden And Not UsedCell.EntireColumn.Hidden Then
If IsNumeric(UsedCell.Value) Then
temp = temp + UsedCell.Value
End If
End If
Next UsedCell
SumVisible = temp
End Function

Bye,
Jay

EDIT: Added Application.Volatile to make it more accurate, but hiding and unhiding rows and columns is not a trappable event, I believe, so be careful when (if) using this.
This message was edited by Jay Petrulis on 2002-04-26 09:29
 
Upvote 0
Tim,

I'd go with Mark's =SUBTOTAL function suggestion, it's different from data / subtotals

it will sum only visible cells when filtering is on - changing the filter criteria will result in a new sum....
 
Upvote 0

Forum statistics

Threads
1,213,560
Messages
6,114,309
Members
448,564
Latest member
ED38

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top