Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Pivot table, need to return the number of filters checked

Status
Not open for further replies.

renigar

Technical User
Jan 25, 2002
111
US
I have a pivot table of data where I need to count the number of filter boxes checked in particular field drop down. I will then use that number for calculations and conditional formatting. I've figured out how to count all the boxes in the filter drop down but not just the checked ones. Can it be done? The field being filtered is a date field for hours. Depending on how many dates are checked will determine what calculations and conditions are set. I'vd tried searching and haven't quite seen what I need. I don't do macros enough to be proficient. Any help would be greatly appreciated.
 


hi,

If you had recorded a macro selecting items, you may have seen a solution.
Code:
    Dim pvi As PivotItem, cnt As Integer
    
    For Each pvi In ActiveSheet.PivotTables("PivotTable1").PivotFields("name").PivotItems
        If pvi.Visible Then cnt = cnt + 1
    Next

    MsgBox "There are " & cnt & " fields selected"

Skip,

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 
Thanks Skip,
This works great. Sometimes the answers are so easy I can;t see them. I appreciate your help.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top