PivotTable Macro Filter

sjack

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

I would like to be able to filter my pivot table by typing into cell D1 e.g. 111111
This Sub is from me just recording a macro of me manually filtering.

Sub Macro2()
'
' Macro2 Macro
'

ActiveSheet.PivotTables("PivotTable1").PivotFields( _
"[Item].[Item Code].[Item Code]").VisibleItemsList = Array( _
"[Item].[Item Code].&[America]&[111111]")

End Sub


Im guessing itll be something like
"[Item].[Item Code].&[America]&Range.D1")
but just not sure how to get that to work

Hopefully this is enough info, first time doing one of these
 

Excel Facts

Can you sort left to right?
To sort left-to-right, use the Sort dialog box. Click Options. Choose "Sort left to right"
Hi,

I would like to be able to filter my pivot table by typing into cell D1 e.g. 111111
This Sub is from me just recording a macro of me manually filtering.

Sub Macro2()
'
' Macro2 Macro
'

ActiveSheet.PivotTables("PivotTable1").PivotFields( _
"[Item].[Item Code].[Item Code]").VisibleItemsList = Array( _
"[Item].[Item Code].&[America]&[111111]")

End Sub


Im guessing itll be something like
"[Item].[Item Code].&[America]&Range.D1")
but just not sure how to get that to work

Hopefully this is enough info, first time doing one of these
This is what i did if anyone else wants to use 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,223,713
Messages
6,174,038
Members
452,542
Latest member
Bricklin

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