sending back error message if pivot filter not available

smakatura

Board Regular
Joined
May 27, 2011
Messages
141
I have a pivot table that has two filters.
  • the month "2018-11"- stored in cell F6
  • the date "11-04-2018" - stored in cell F3

I am using the code below to sort my pivot by these values
Code:
ActiveSheet.PivotTables("PivotTable2").PivotFields("Month").CurrentPage = Range("g6").Value
                    ActiveSheet.PivotTables("PivotTable2").PivotFields("Date").CurrentPage = Range("g3").Value


this works fine when both the date and month are options.
I want when
  1. the date is there but not the month, select ALL for the month
  2. when the date is missing, do not select anthing....so thee would be no rows in the pivot (this way when I do my lookup of one of the pivot fields (later in the code), it returns NA bc it is not there
 

Excel Facts

Save Often
If you start asking yourself if now is a good time to save your Excel workbook, the answer is Yes

Forum statistics

Threads
1,223,214
Messages
6,170,774
Members
452,353
Latest member
strainu

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
Back
Top