muhleebbin
Active Member
- Joined
- Sep 30, 2017
- Messages
- 252
- Office Version
- 365
- 2019
- 2016
- 2013
- 2010
- Platform
- Windows
- MacOS
- Mobile
- Web
Is it possible to make var1 in the following code conditional to its existence or not?
Basically i'm trying to use a pivot table to help produce a report on attendees for each day of our event. var2 will always be a selection but var1 will eventually have Friday Only, Saturday Only, Sunday Only passes, however those aren't issued yet.
When testing, the current code runs into issues if a day specific pass isn't issued yet so i'd like to make var1 conditional but can't seem to figure out how to do that.
Basically i'm trying to use a pivot table to help produce a report on attendees for each day of our event. var2 will always be a selection but var1 will eventually have Friday Only, Saturday Only, Sunday Only passes, however those aren't issued yet.
When testing, the current code runs into issues if a day specific pass isn't issued yet so i'd like to make var1 conditional but can't seem to figure out how to do that.
Code:
var1 = Worksheets("Sheet1").Range("S1")
var2 = "THREE DAY PASS"
n = 0
With Worksheets("Sheet1").PivotTables("PivotTable19").PivotFields("Day(s)") '.PivotFilters
.ClearAllFilters
For Each Pi In .PivotItems
Select Case Pi.Name
Case var1, var2
Pi.Visible = True
Case Else
n = n + 1
If n < .PivotItems.Count Then
Pi.Visible = False
Else
.ClearAllFilters
End If
End Select
Next
End With