Pivot Tables - using .AutoShow
For the benefit of others, I worked out a solution, which is to add
the DataField first, then AutoSort and AutoShow, then add the RowField
and ColumnField. My code looks like this:
Set pt = ws.PivotTables("ptTest")
With pt
.AddDataField .PivotFields("Blah"), "Sum of Blah", xlSum
With .PivotFields("CauseCatType")
.AutoSort xlDescending, "Sum of Blah"
.AutoShow xlAutomatic, xlTop, 8, "Sum of Blah"
End With
.AddFields "CauseCatType", "Category"
End With
|