Thread: DIm Variables
View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Jake Marx[_3_] Jake Marx[_3_] is offline
external usenet poster
 
Posts: 860
Default DIm Variables

Hi Todd,

As Bob notes, you must use As Object (or As PivotField) for each variable.
An array of objects would work, as others have noted.

Alternatively, you could use a collection to store your data:

Dim colDF As Collection
Dim pf As PivotField

Set colDF = New Collection

For Each pf In Sheet1.PivotTables(1).PivotFields
colDF.Add pf
Next pf


'/ get count of items in collection
Debug.Print colDF.Count

'/ show first item in collection
Debug.Print colDF(1).Name & ": " & colDF(1).DataType

--
Regards,

Jake Marx
MS MVP - Excel
www.longhead.com

[please keep replies in the newsgroup - email address unmonitored]


Todd Huttenstine wrote:
Hey guys I have 70 variables. Each one of these variables
is equal to a DataField in a PivotTable.

I am creating a variable for each field so I can
programmatically control them from a listbox.

Now because I have 70 fields I need 70 variables. What
should I set the variable to and how should I do it with
the least amount of code. Many times I have seen the
following for example:

Dim ExmplVariable as Object, ExmplVariable2, ExmplVariable3

Can I do this all on one line and do I have to use "as
object" for each variable or can I do it only once?

Thanks
Todd Huttenstine