Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I was given this code and have been messing around with it all day and have
not been able to figure out why it does not work. This code is on the same sheet as the pivot table, and on the Immediate Window I have:Application.EnableEvents = True the error I am getting when I type in a value to find in my pivot table is: Run-time error '1004': Unable to set the Visible property of the PivotItem class I have tried everything I can think of to make this work, does anyone have any idea what i am doing wrong? thank you. here is the code? Private Sub Worksheet_Change(ByVal Target As Range) If Target.Row < 1 Or Target.Column < 6 Then Exit Sub Dim pi As PivotItem, pf As PivotField Application.EnableEvents = False Application.ScreenUpdating = False ' change name of Pivto Table and Pivot Field to your values on next Set pf = ActiveSheet.PivotTables("PivotTable1").PivotFields ("WOJO1") With pf pf.AutoSort xlManual, pf.SourceName For Each pi In pf.PivotItems pi.Visible = True Next For Each pi In pf.PivotItems If pi.Name < Range("F1").Value Then pi.Visible = False End If Next pf.AutoSort xlAutomatic, pf.SourceName End With Application.ScreenUpdating = False Application.EnableEvents = True End Sub |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Run a VB code when you click on the data field of a Pivot Table | Excel Discussion (Misc queries) | |||
Pivit table- cell on spread sheet referencing pivot table field | Charts and Charting in Excel | |||
Change a pivot table field by typing into another cell | Excel Discussion (Misc queries) | |||
Selecting values in the page field of a pivot table | Excel Programming | |||
Pivot table field swapping in code | Excel Programming |