Having a pivot table, I need to apply a filter with 1) a specific date and 2) data sets without a date.
I have tried the makro but it stops at " .PivotItems(i).Visible = False" in the first loop where i=1
Sub YesterdayBlank()
ActiveSheet.PivotTables("PivotTable2").ClearAllFilters
Dim yesterday As Date
yesterday = ActiveSheet.Range("F1").Value
Dim taeller As String
taeller = ActiveSheet.PivotTables("PivotTable2").PivotFields("OrderDate").PivotItems.Count
With ActiveSheet.PivotTables("PivotTable2").PivotFields("OrderDate")
For i = 1 To taeller
If .PivotItems(i) <> ("blank") And .PivotItems(i) <> yesterday Then
.PivotItems(i).Visible = False
Else
.PivotItems(i).Visible = True
End If
Next i
End With
End Sub
Any suggestions?
TomDK
I have tried the makro but it stops at " .PivotItems(i).Visible = False" in the first loop where i=1
Sub YesterdayBlank()
ActiveSheet.PivotTables("PivotTable2").ClearAllFilters
Dim yesterday As Date
yesterday = ActiveSheet.Range("F1").Value
Dim taeller As String
taeller = ActiveSheet.PivotTables("PivotTable2").PivotFields("OrderDate").PivotItems.Count
With ActiveSheet.PivotTables("PivotTable2").PivotFields("OrderDate")
For i = 1 To taeller
If .PivotItems(i) <> ("blank") And .PivotItems(i) <> yesterday Then
.PivotItems(i).Visible = False
Else
.PivotItems(i).Visible = True
End If
Next i
End With
End Sub
Any suggestions?
TomDK