Clearing DataFields
Hi all,
Got a question that;s driving me crazy here, and I'm hoping someone can point out my error. I have a macro that I use to clear out all the DataFields of a pivot table and reinsert the fields I want, in the order I need it in. The problem I have is if there is only one Field in the DataField part of the Pivot. If there is multiple, I can get the code to work without any problems. Here's the code: If Sheets("pivottable").PivotTables("PivotTable").Dat aFields.Count = 1 Then For Each pvtField In Sheets("pivottable").PivotTables("PivotTable").Dat aFields ' this causes an error ' Unable to set the Orientation property of the PivotField class (1004) pvtField.Orientation = xlHidden Next pvtField Else ' this works fine For Each pvtField In Sheets("pivottable").PivotTables("PivotTable").Col umnFields pvtField.Orientation = xlHidden Next pvtField End If I don't know how I can get the dataFields cleared when there's only one. If anyone can provide some help, I'd appreciate it. Thanks, Jay |
All times are GMT +1. The time now is 04:13 PM. |
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com