![]() |
![]() |
|
|||||||
| Excel Questions All Excel/VBA questions - formulas, macros, pivot tables, general help, etc. Please post to this forum in English only. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Board Regular
Join Date: Feb 2002
Posts: 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
|
|
|
|
|
|
#2 |
|
MrExcel MVP
Join Date: Feb 2002
Location: Austin, Texas USA
Posts: 11,654
|
Have you tried using the SUBTOTAL worksheet function?
|
|
|
|
|
|
#3 |
|
Board Regular
Join Date: Feb 2002
Posts: 129
|
Yes, I don't want to use subtotals in this job. Is there another way?
|
|
|
|
|
|
#4 |
|
MrExcel MVP
Join Date: Feb 2002
Location: The Hague
Posts: 50,319
|
Try to use the filter criteria directly in a SUMPRODUCT formula if you must.
|
|
|
|
|
|
#5 |
|
MrExcel MVP
Join Date: Mar 2002
Location: Chicago, IL USA
Posts: 2,042
|
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 ] |
|
|
|
|
|
#6 |
|
MrExcel MVP
Join Date: Feb 2002
Location: Millbank, London, UK
Posts: 1,790
|
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....
__________________
:: Pharma Z - Family drugstore :: |
|
|
|
![]() |
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|