View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Quietman Quietman is offline
external usenet poster
 
Posts: 109
Default Loading pivotfields from an array

I'm using th code below, is this the most efficient way to use the array?

Sub Load_PivotFields()
Dim DataFieldArray As Variant, Pivot_Field As String, Sht_Select As String
Application.ScreenUpdating = False
Sheets("Formulas").Select
DataFieldArray = Range(Cells(100, 1), Cells(147, 8)).Value
For w = 1 To 8
ActiveSheet.Next.Select
Sht_Select = ActiveSheet.Name
For x = 1 To UBound(DataFieldArray)
Pivot_Field = DataFieldArray(x, w)
ActiveSheet.PivotTables("PivotTable1").AddDataFiel d
ActiveSheet.PivotTables("PivotTable1").PivotFields (Pivot_Field), "Sum of " &
Pivot_Field, xlSum
Nex x
Next w
Application.ScreenUpdating = True
End Sub

--
Helping Is always a good thing