View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
GS[_2_] GS[_2_] is offline
external usenet poster
 
Posts: 3,514
Default Adding PivotTable fields with a macro

In order to get rid of With...End With you need to fully qualify each
line of executable code. The purpose of With...End With constructs is
to reduce the amount of DOT processing, and thus render more efficient
code.

Try...

With ActiveSheet.PivotTables("PivotTable2")
With .PivotFields("Fruit")
.Orientation = xlRowField: .Position = 4
.Orientation = xlRowField: .Position = 1
End With
With .PivotFields("Cost")
.Orientation = xlRowField: .Position = 5
.Orientation = xlRowField: .Position = 2
End With
End With

--
Garry

Free usenet access at http://www.eternal-september.org
ClassicVB Users Regroup! comp.lang.basic.visual.misc