question

WongChuiChing-3047 avatar image
0 Votes"
WongChuiChing-3047 asked WongChuiChing-3047 answered

Sort Pivot table based on subtotal

When I search for

PivotField.AutoSort

method: excel.pivotfield.autosort, there is a Parameter called CustomSubtotal.

Anyone have the sample, what should I put in for this parameter?

Here the sample table KH0d6.png

The main objective is use vba to autosort PivotTable based on "C Total".

From eCMQj.png to pVv8h.png

I had tried both code below, cannot work.

 With pvt
  .PivotFields("Field 1").AutoSort(Order:=Excel.XlSortOrder.xlDescending, Field:="Field 2", CustomSubtotal:="C Total")
 End With
    
 With pvt
  .PivotFields("Field 1").AutoSort(Order:=Excel.XlSortOrder.xlDescending, Field:="Field 2", CustomSubtotal:="C")
 End With

Thanks.


office-vba-dev
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

WongChuiChing-3047 avatar image
0 Votes"
WongChuiChing-3047 answered
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.