Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 38
Default Data Fields in Pivot Table

I'm trying to write a macro that will clear all fields in my pivot table
including the data fields. I have the following:

On Error Resume Next
Dim pt As PivotTable
Dim pf As PivotField

Sheets(4).PivotTables("PivotTable2").ClearAllFilte rs
Set pt = Sheets(4).PivotTables(2)
With pt
For Each pf In .VisibleFields
pf.Orientation = xlHidden
Next pf
End With

The macro above clears all fields except the data fields. Any ideas for what
I could add to the macro to make it also clear the data fields?

Thanks.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 38
Default Data Fields in Pivot Table

I just realized that the problem wasn't in the macro but in fact in the pivot
table name. When I changed pivottables(2) to pivottable("PivotTable2") it
worked. Thanks again.

"Debra Dalgleish" wrote:

Your code works for me. Are all the data fields left in the layout?

MichaelR wrote:
I'm trying to write a macro that will clear all fields in my pivot table
including the data fields. I have the following:

On Error Resume Next
Dim pt As PivotTable
Dim pf As PivotField

Sheets(4).PivotTables("PivotTable2").ClearAllFilte rs
Set pt = Sheets(4).PivotTables(2)
With pt
For Each pf In .VisibleFields
pf.Orientation = xlHidden
Next pf
End With

The macro above clears all fields except the data fields. Any ideas for what
I could add to the macro to make it also clear the data fields?

Thanks.



--
Debra Dalgleish
Contextures
www.contextures.com/tiptech.html
Blog: http://blog.contextures.com


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
subtracting two pivot table data fields Alok Charts and Charting in Excel 1 November 14th 09 01:54 AM
subtract two data fields in pivot table Alok Charts and Charting in Excel 0 October 31st 09 08:50 PM
VBA Pivot Table help with data fields James Excel Discussion (Misc queries) 3 August 13th 09 05:15 PM
Data Fields in Pivot Table MichaelR Excel Discussion (Misc queries) 0 July 22nd 08 06:36 PM
delete pivot table data fields geebee Excel Programming 1 April 18th 08 01:16 PM


All times are GMT +1. The time now is 06:18 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"