PC Review


Reply
Thread Tools Rate Thread

Data Fields in Pivot Table

 
 
MichaelR
Guest
Posts: n/a
 
      22nd Jul 2008
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").ClearAllFilters
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.
 
Reply With Quote
 
 
 
 
Debra Dalgleish
Guest
Posts: n/a
 
      22nd Jul 2008
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").ClearAllFilters
> 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 With Quote
 
MichaelR
Guest
Posts: n/a
 
      24th Jul 2008
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").ClearAllFilters
> > 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 With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Pivot Table not pulling all fields or data clr Microsoft Excel Programming 0 27th Nov 2009 01:40 AM
VBA Pivot Table help with data fields James Microsoft Excel Misc 3 13th Aug 2009 05:15 PM
Can I Sort (A-Z or Z-A) Pivot Table Data or Fields using VBA? MikeZz Microsoft Excel Programming 4 5th Mar 2009 02:48 PM
Data Fields in Pivot Table MichaelR Microsoft Excel Misc 0 22nd Jul 2008 06:36 PM
Pivot Table Data Fields Won't Total Dave Y Microsoft Excel Charting 0 4th Mar 2004 04:40 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 07:26 AM.