Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Getting values of a pivot table field into a string/array in VBA

Status
Not open for further replies.

VBAguy22

IS-IT--Management
Aug 5, 2003
180
CA
Hi
I have a pivot table PivotX on Sheet1 of my Workbook.
I need to be able to retrieve all the values in the pivot table's field Names into some sort of VBA variable (array or String).
Is there a way?
Thanks!
 


Hi,

Loop thru the values and load them into an array.

What have you tried so far?

Skip,

[glasses] [red]A palindrome gone wrong?[/red]
A man, a plan, a ROOT canal...
PULLEMALL![tongue]
 
Object model should give you this:
Code:
For Each pvtfld In ActiveSheet.PivotTables(1).PivotFields
    MsgBox pvtfld.Name
Next

or 

with ActiveSheet.PivotTables(1)
    for i = 1 to .PivotFields.count
        myArray(i-1) = .pivotfields(i).name
    next i
end with

If I have read your request wrong, the next level down is pivotITEMS (within a pivotFIELD)

Rgds, Geoff

We could learn a lot from crayons. Some are sharp, some are pretty and some are dull. Some have weird names and all are different colours but they all live in the same box.

Please read FAQ222-2244 before you ask a question
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top