Hi All,
Earlier I have with success used below code, to update a filter in a PivotTable.
Now I have another PivotTable, but this time the Filter is a date instead of a Text.
I have tried changing below to "Dim xStr As Date" and "xStr = Target.Value" but it doesn't seem to work.
Can anyone help me, how to change below code, so it will work on a date?
/Skovgaard
Earlier I have with success used below code, to update a filter in a PivotTable.
Now I have another PivotTable, but this time the Filter is a date instead of a Text.
I have tried changing below to "Dim xStr As Date" and "xStr = Target.Value" but it doesn't seem to work.
Can anyone help me, how to change below code, so it will work on a date?
VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)
Dim xPTable As PivotTable
Dim xPFile As PivotField
Dim xStr As String
On Error Resume Next
If Intersect(Target, Range("G1:G2")) Is Nothing Then Exit Sub
Application.ScreenUpdating = False
Set xPTable = Worksheets("PivotMonth").PivotTables("PivotTable1")
Set xPFile = xPTable.PivotFields("YYYYMM:")
xStr = Target.Text
xPFile.ClearAllFilters
xPFile.CurrentPage = xStr
Application.ScreenUpdating = True
End Sub
/Skovgaard