How to select date in pivot table filter using VBA | بلاگ

How to select date in pivot table filter using VBA

تعرفه تبلیغات در سایت

آخرین مطالب

امکانات وب

Vote count: 0

I have a pivot table. I would like to select only one date from the filter (Report Filter) every month. That is, i need to make only one pivot item visible and others invisible. The date is 01.02.2018, for next month 01.03.2018 and so on.

I used the code but not working and showing error unable to get the pivotitems property of the pivotfield class. I think, The problem is in Date format. How to solve this. Help me

Sub Selectdate()

Dim dat As String
Toddat = DateSerial(Year(Date), Month(Date), 1)
dat = Format(Toddat, "dd/mm/yyyy")

ActiveSheet.PivotTables("PivotTable2").PivotFields("Recieved Date").CurrentPage = "(All)"

With ActiveSheet.PivotTables("PivotTable2").PivotFields("Recieved Date")
         .PivotItems(dat).Visible = True
End With
End Sub

When i record with macro, the code is

With ActiveSheet.PivotTables("PivotTable2").PivotFields("Recieved Date")
    .PivotItems("01/02/2018").Visible = True
End With
asked 38 secs ago
Deepak

...
نویسنده : استخدام کار بازدید : 9 تاريخ : سه شنبه 24 بهمن 1396 ساعت: 20:57