Neeraj Dhiman
New Member
Hi All,
Need to understand the problem with below code. I am trying to filter the data between two dates however the below codes is working but its not selecting all the dates between the defined dates set. Please help me here
Start date is : 1 Jan 2019
End Date is : 31 mar2019
Code:-
Need to understand the problem with below code. I am trying to filter the data between two dates however the below codes is working but its not selecting all the dates between the defined dates set. Please help me here
Start date is : 1 Jan 2019
End Date is : 31 mar2019
Code:-
Code:
Sub PageItemFilter()
Dim pvtF As PivotField
Dim pvtI As PivotItem
Set pvtF = Worksheets("PivotTables").PivotTables("PivotTable1").PivotFields("Date")
For Each pvtI In pvtF.PivotItems
If DateValue(pvtI.Name) >= Range("C2").Value2 And DateValue(pvtI.Name) <= Range("C3").Value2 Then
pvtI.Visible = True
Else
pvtI.Visible = False
End If
Next pvtI
End Sub
Last edited by a moderator: