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".
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.