If it is possible please can someone provide the code that will enable me to automate the process of changing filters for week numbers on numerous pivot tables?
I produce a weekly report that requires a 10 week period range. Therefore, every week I have to remove from numerous pivot tables the Week filter that has become the 11th week and add to the Week filter the previous week.
I have provided a recorded macro version of the process and a screen shot of the table to help explain. I've tried various searches but I cannot find anything relevant. Any help that can be provided I will greatly appreciate as I am currently learning VBA.
Image: https://imgur.com/a/gYx4j
I produce a weekly report that requires a 10 week period range. Therefore, every week I have to remove from numerous pivot tables the Week filter that has become the 11th week and add to the Week filter the previous week.
I have provided a recorded macro version of the process and a screen shot of the table to help explain. I've tried various searches but I cannot find anything relevant. Any help that can be provided I will greatly appreciate as I am currently learning VBA.
Image: https://imgur.com/a/gYx4j
Code:
<code>Sub Macro2()
'
' Macro2 Macro
'
'
Range("B15").Select
ActiveSheet.PivotTables("TopPvt").PivotCache.Refresh
With ActiveSheet.PivotTables("TopPvt").PivotFields("Week")
.PivotItems("45").Visible = False
.PivotItems("3").Visible = True
End With
Range("B21").Select
End Sub</code>