Hi,
Look http://www.gcflearnfree.org/excel2007/18.4
or simply click in a column heading and then move the cursor so it selects the side of the cell, click and drag it to where you want.
My experience has lead me to write a lot less code and use more and more of the standard features of Excel. It is, of course, to write code to do all this but it then becomes less useful when things change.
Using the example Pivot I supplied above. I turned on the macro recorder and drug column C to the front and then column D. The code generated was:
Sub Macro1()
ActiveSheet.PivotTables("PivotTable1").DataPivotField.PivotItems("Sum of C"). _
Position = 1
ActiveSheet.PivotTables("PivotTable1").DataPivotField.PivotItems("Sum of D"). _
Position = 2
End Sub
Recording macros and then seeing what I did in VBA is my method for learning.
Bookmarks