Filtering Pivot Table Based on Cell Value

John_356

New Member
Joined
Jan 17, 2021
Messages
26
Office Version
  1. 365
Platform
  1. Windows
Good day,

Been trying to figure out a solution to filter my pivot table based on a cell value; that cell is on another worksheet used as dashboard and the whole story is about automating reportings.

Location of reference cell:
VBA Code:
Worksheets("S").Range("J14")

Primary objective: Below numbers from 1 to 12 are Months and I'm looking for an elegant if solution to link them to above reference.

Secondary objective: If the reference is blank then all Months should be selected.

Current filtering is off for all Months:
VBA Code:
With Worksheets("PivotTable").PivotTables("SalesPivotTable").PivotFields("Month")
    .PivotItems("1").Visible = False
    .PivotItems("2").Visible = False
    .PivotItems("3").Visible = False
    .PivotItems("4").Visible = False
    .PivotItems("5").Visible = False
    .PivotItems("6").Visible = False
    .PivotItems("7").Visible = False
    .PivotItems("8").Visible = False
    .PivotItems("9").Visible = False
    .PivotItems("10").Visible = False
    .PivotItems("11").Visible = False
    .PivotItems("12").Visible = False

Many thanks in advance to whomever will get this one!

Cheers

J
 

Excel Facts

Pivot Table Drill Down
Double-click any number in a pivot table to create a new report showing all detail rows that make up that number

Forum statistics

Threads
1,136,864
Messages
5,678,216
Members
419,752
Latest member
TryingtoLearnVBA

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