Pivot Table Filtering

speth

New Member
Joined
Feb 18, 2013
Messages
27
I'm having trouble filtering what's in a pivot table using VBA. I have a large pivot table, but for sake of brevity, the attached sample is essentially the same thing.

In this sample, I'm getting kicked back with a 1004 error that it can't find the referenced PivotField. Here's the code....

Code:
Sub PIVOT_TEST()
Sheets("Sheet2").PivotTables("PivotTable2").PivotFields("Number")PivotItem("4").Visible = False
End Sub

Here's the data that's sent to the pivot table. The VBA is running after the table has been created (Sheet2).


NumberName
1Bob
2Jim
3Sam
4Bill
5
6Ted
7Amy
8Becca
9Josh
10

<tbody>
</tbody>


Any suggestions?
 

Excel Facts

How can you automate Excel?
Press Alt+F11 from Windows Excel to open the Visual Basic for Applications (VBA) editor.
Doesnt seem anything wrong with the code. Check spelling etc. Record the action and see if yours looks like the recording.
 
Upvote 0

Forum statistics

Threads
1,215,890
Messages
6,127,597
Members
449,386
Latest member
owais87

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