Hi Guys,
I am trying to write VBA to do a simple sort based on the following:
Col A = Unit, Col B = ID, Col C = Date, Cole E = Count of FOB.
I wish to sort on Col D to be descending and to include all fields in the row as it goes through. There are about 700 rows.
I have attempted the following code:
Dim pt As PivotTable
Dim pf As PivotField
Set pt = ActiveSheet.PivotTables("PivotTable1")
Set pf = ActiveSheet.PivotTables("PivotTable1").PivotFields("Unit")
For Each pf In pt.RowFields
pf.AutoSort xlDescending, "Count of FOB"
Next pf
==========================================================
I have also attached a screen grab of part of the pivot table data as an example.
I am trying to write VBA to do a simple sort based on the following:
Col A = Unit, Col B = ID, Col C = Date, Cole E = Count of FOB.
I wish to sort on Col D to be descending and to include all fields in the row as it goes through. There are about 700 rows.
I have attempted the following code:
Dim pt As PivotTable
Dim pf As PivotField
Set pt = ActiveSheet.PivotTables("PivotTable1")
Set pf = ActiveSheet.PivotTables("PivotTable1").PivotFields("Unit")
For Each pf In pt.RowFields
pf.AutoSort xlDescending, "Count of FOB"
Next pf
==========================================================
I have also attached a screen grab of part of the pivot table data as an example.