Filter Pivottable with Macro

sjack

New Member
Joined
Sep 1, 2021
Messages
4
Platform
  1. Windows
Hi,

I think im pretty close to getting this working im just not sure what to set my Path As.
What im attempting is to be able to filter my pivot table in the Item Code category by a chosen item number e.g. 111111, I want to just type the number in cell G9 and then that will automatically filter the pivot table to that value.

Sub Macro1()
'
' Macro1 Macro
'
Dim Path As ?????
Path = Range("G9").Value
ActiveSheet.PivotTables("PivotTable1").PivotFields( _
"[Item].[Item Code].[Item Code]").VisibleItemsList = Array( _
"[Item].[Item Code].&[Australia]&(Path)")

End Sub
 

Excel Facts

Workdays for a market open Mon, Wed, Friday?
Yes! Use "0101011" for the weekend argument in NETWORKDAYS.INTL or WORKDAY.INTL. The 7 digits start on Monday. 1 means it is a weekend.
Figured it out, this is what i did if anyone needs it.

ActiveSheet.PivotTables("PivotTable1").PivotFields( _
"[Item].[Item Code].[Item Code]").VisibleItemsList = Array( _
"[Item].[Item Code].&[Australia]&[" & Worksheets("Control").Range("D1").Value & "]")
 
Upvote 0

Forum statistics

Threads
1,214,626
Messages
6,120,602
Members
448,974
Latest member
ChristineC

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