smpggrl
01-15-2009, 09:16 AM
Hi, I have read as much as I can about this topic but anything I try is not working. If you look at my code (below), it seems like it should work but even though it compiles, it refuses to execute. I would appreciate any help you can give. Thanks!
Dim pt As PivotTable
Dim pf As PivotField
Dim pi As PivotItem
Dim strCri As String
Dim pos As Long
Set pt = Sheet5.PivotTables("PivotTable1")
Set pf = pt.PivotFields("Deal Name")
strCri = "$000.00"
Application.ScreenUpdating = False
pt.ManualUpdate = True
With pf
.AutoSort xlManual, .SourceName
'On Error Resume Next
For Each pi In pf.PivotItems
pos = InStr(1, pi, strCri)
If pos = 0 Then
Else:
pi.Visible = False
MsgBox (pi)
End If
Next pi
.AutoSort xlAscending, .SourceName
End With
The message box shows the correct value that should be hidden, but it does not become hidden when I run the macro.
Dim pt As PivotTable
Dim pf As PivotField
Dim pi As PivotItem
Dim strCri As String
Dim pos As Long
Set pt = Sheet5.PivotTables("PivotTable1")
Set pf = pt.PivotFields("Deal Name")
strCri = "$000.00"
Application.ScreenUpdating = False
pt.ManualUpdate = True
With pf
.AutoSort xlManual, .SourceName
'On Error Resume Next
For Each pi In pf.PivotItems
pos = InStr(1, pi, strCri)
If pos = 0 Then
Else:
pi.Visible = False
MsgBox (pi)
End If
Next pi
.AutoSort xlAscending, .SourceName
End With
The message box shows the correct value that should be hidden, but it does not become hidden when I run the macro.