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

Do you hate GETPIVOTDATA?
Prevent GETPIVOTDATA. Select inside a PivotTable. In the Analyze tab of the ribbon, open the dropown next to Options and turn it off
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,214,641
Messages
6,120,684
Members
448,977
Latest member
dbonilla0331

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