I have a file with pivot tables where the filter values are updated on a monthly basis based on the last month's date. VBA code for this:
Dim SelectDate As String
SelectDate = Worksheets("Raw").Range("A3").Value
Worksheets("Main").PivotTables("PivotTable4").PivotFields("Date").CurrentPage = SelectDate
The value in cell A3 is string based on the following function:
=A1&" "&A2
For example: January 2017
Updating the pivot tables worked fine for several months, but for this month my values no longer update correctly and after doing some investigation I realized that my pivot table has created two entries in the filter for the month January 2017
and January 20172
, while November 2016
went missing:
However, when I check my underlying data, I only have one value for each month:
June 2016
February 2016
March 2016
January 2016
November 2016
December 2016
August 2016
May 2016
October 2016
July 2016
September 2016
April 2016
January 2017
February 2017
Note that when I create an new Pivot table with the same data, the filter only shows January 2017
.
Any suggestions why the filter for the existing pivot table would reflect both January 2017
and January 20172
?
Thanks for your help!
Here is what worked for me. This happened from what I have read elsewhere either because I added now data lines or because I did a find-and-replace. But then I changed the area of the source data in the pivot table from say
'MASTER (3)'!$A$5:$EQ$600 to 'MASTER (3)'!$A$5:$EQ$6
and then back to
'MASTER (3)'!$A$5:$EQ$600
This resolved the problem
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With