James McMillan
New Member
- Joined
- Jan 18, 2011
- Messages
- 3
I have created the following coded to filter a pivot table:
ActiveSheet.PivotTables("PivotTable1").PivotFields("G/L Acct").ClearAllFilters
With ActiveSheet.PivotTables("PivotTable1").PivotFields("G/L Acct")
For i = 1 To .PivotItems.Count
If .PivotItems(i).Value = "066930" Or "077697" Then
.PivotItems(i).Visible = True
Else
.PivotItems(i).Visible = False
End If
Next
End With
If I set the PivotItems.value to just one value, the code works, but if I try to set it to equal more than one value it does not. Am I using the OR function correctly?
Thanks for your help.
ActiveSheet.PivotTables("PivotTable1").PivotFields("G/L Acct").ClearAllFilters
With ActiveSheet.PivotTables("PivotTable1").PivotFields("G/L Acct")
For i = 1 To .PivotItems.Count
If .PivotItems(i).Value = "066930" Or "077697" Then
.PivotItems(i).Visible = True
Else
.PivotItems(i).Visible = False
End If
Next
End With
If I set the PivotItems.value to just one value, the code works, but if I try to set it to equal more than one value it does not. Am I using the OR function correctly?
Thanks for your help.