Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
Jay Jay is offline
external usenet poster
 
Posts: 671
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Counting number of unique datafields in a column johan Excel Discussion (Misc queries) 2 October 19th 09 07:58 PM
Clearing cells without clearing formulas marsjune68 Excel Discussion (Misc queries) 2 April 10th 09 07:39 PM
Clearing #VALUE skateblade Excel Worksheet Functions 3 October 15th 05 10:34 PM
Pivot Table DataFields are appended with a '2', why? SunshineX Excel Discussion (Misc queries) 1 July 12th 05 06:15 PM
Changing Names of Pivot datafields mo_in_france Excel Programming 3 January 20th 05 09:51 AM


All times are GMT +1. The time now is 03:25 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"