Pivot Table Orientation = xlHidden

StuLux

Well-known Member
Joined
Sep 14, 2005
Messages
679
Office Version
  1. 365
Platform
  1. Windows
I have recorded VBA code as follows:

Code:
    ActiveSheet.PivotTables("Months").PivotFields("YTD Var").Orientation = xlHidden

but I get the error "Unable to set the orientation property of the PiuvotField class"

Anybody know why - all I can find suggests this is the correct way to hide a field in a pivot table?
 

Excel Facts

Whats the difference between CONCAT and CONCATENATE?
The newer CONCAT function can reference a range of cells. =CONCATENATE(A1,A2,A3,A4,A5) becomes =CONCAT(A1:A5)
I know this is a very very old thread but I had a similar problem. So to help the next person, if the data field is a calculated data field (not sure if it was in the above post), in Excel 2007 the VBA code recorded by the macro recorder when you remove a calculated data field from a pivot table is something like:
ActiveSheet.PivotTables("My Pivot Table").PivotFields("My calculated field").Orientation = xlHidden
which works on a normal data field but for calculated fields when you run the macro it causes the Run-time error '1004': Unable to get the PivotFields property of the PivotTable class.
You can instead use:
ActiveSheet.PivotTables("My Pivot Table").PivotFields("My calculated field").Delete
(and if later on you need that calculated field again you have to add it again)

This thread helped:
http://social.msdn.microsoft.com/Forums/en/isvvba/thread/60fa78ed-0913-4bf5-9c47-2bc0eea59a2c
 
Upvote 0
Oops, that error was actually
Run-time error '1004': Unable to set the Orientation property of the PivotField class
(see above post)
 
Upvote 0

Forum statistics

Threads
1,214,429
Messages
6,119,435
Members
448,898
Latest member
dukenia71

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