Why is this date filter not working?

bcurrey

Board Regular
Joined
Aug 11, 2011
Messages
101
I have 3 pivot tables and I'm filtering them by Prior day, Current Month, Current year.

The prior day and the Yearly filters work. I can't get the current month to work (highlighted in red below).

The error I'm getting says "Run-time error 1004. Application-defined or object-defined error"

The month is spelled out in the data I'm using. ex: "October".


Any ideas? I know it's probably something simple.

Thanks!


Code:
   ActiveSheet.PivotTables("PivotTable4").PivotFields("Date").ClearAllFilters
   ActiveSheet.PivotTables("PivotTable4").PivotFields("Date").CurrentPage = (Date - 1)
   
   ActiveSheet.PivotTables("PivotTable5").PivotFields("Month").ClearAllFilters
[COLOR=Red][B]   ActiveSheet.PivotTables("PivotTable5").PivotFields("Month").CurrentPage = MonthName(Month(Date))[/B][/COLOR]
   
   ActiveSheet.PivotTables("PivotTable6").PivotFields("Year").ClearAllFilters
   ActiveSheet.PivotTables("PivotTable6").PivotFields("Year").CurrentPage = Year(Date)
 

Some videos you may like

Excel Facts

Remove leading & trailing spaces
Save as CSV to remove all leading and trailing spaces. It is faster than using TRIM().

AlphaFrog

MrExcel MVP
Joined
Sep 2, 2009
Messages
16,378
In your data...

Is the month a Text string e.g. "October" (good)

Or is it a date with a format to display as month (Bad)
10/26/2011 formatted to display as "mmmm" which will look like "October"
 

bcurrey

Board Regular
Joined
Aug 11, 2011
Messages
101
Appreciate the response. You helped me find the issue. The month is spelled out as "October" (not a date). However, there are spaces (varying number) after the word.
 

Watch MrExcel Video

Forum statistics

Threads
1,122,464
Messages
5,596,288
Members
414,052
Latest member
Dual Showman

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top