Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Counting number of unique datafields in a column | Excel Discussion (Misc queries) | |||
Clearing cells without clearing formulas | Excel Discussion (Misc queries) | |||
Clearing #VALUE | Excel Worksheet Functions | |||
Pivot Table DataFields are appended with a '2', why? | Excel Discussion (Misc queries) | |||
Changing Names of Pivot datafields | Excel Programming |