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

I have a pivot table with multiple data fields. However, I do not
want to display all the data fields at the same time. I would like to
write a macro which loops through all the data fields and refreshes
the table upon doin so. At any given time I only want one data field
to be displayed.

My data fields are named Aco, Bco, Cco, and Dco.

So if Aco is shown, I want Bco, Cco and Dco to be hidden. Is ther
any easy way to put these in a loop so that I can do this?

TS
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 473
Default Pivot Table Question

wrote:
So if Aco is shown, I want Bco, Cco and Dco to be hidden. Is ther
any easy way to put these in a loop so that I can do this?


You will need some form of user interaction to say "ready to look at
next item" - maybe a button on the worksheet.

I guess the following (untested) procedure might do it:

Sub NextData()
Dim vFields
Dim iField As Integer
vFields = Array("Aco", "Bco", "Cco", "Dco")
With ActiveSheet.PivotTables("PivotTable5")
For iField = LBound(vFields) To UBound(vFields)
If .PivotFields(vFields(iField)).Orientation = xlDataField Then
.DataFields(1).Orientation = xlHidden
If iField < UBound(vFields) Then
.PivotFields(iField+1).Orientation = xlDataField
Else
.PivotFields(LBound(vFields)).Orientation = xlDataField
End If
Exit For
End If
Next
End With
End Sub

Bill Manville
MVP - Microsoft Excel, Oxford, England
No email replies please - reply in newsgroup

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
Pivot Table Question + Connie Martin Excel Discussion (Misc queries) 4 March 11th 09 07:14 PM
Pivot Table Question - HELP! Fill-in Form General Questions Excel Discussion (Misc queries) 2 April 21st 08 06:24 PM
pivot table question Sanj Excel Worksheet Functions 1 September 1st 06 12:27 AM
Pivot Table Question : If statment in Pivot Table?? seve Excel Discussion (Misc queries) 2 November 22nd 05 01:00 AM
Pivot Table Question dallin Excel Worksheet Functions 1 September 12th 05 05:54 PM


All times are GMT +1. The time now is 04:08 PM.

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

About Us

"It's about Microsoft Excel"