Hi,
I am getting error while running a vb activity.
And getting this error.
Can anyone help please?
@supermanPunch @ushu @Gokul001 @Anil_G
@shreyash_shirbhate
Sub SortPivotColumn()
Dim PT As PivotTable
Set PT = ActiveSheet.PivotTables(“PivotTable6”)
With PT.PivotSelect(“Branch/Plant”)
.Orientation = xlLabelOnly
.SortOnValue = True
.SortOrder = xlAscending
End With
End Sub
I am sorry but I cannot share the excel sheet because it contain sensitive data.
-
make sure your pivot table is the correct name i.e. PivotTable6. If its wrong, change name and run again
-
if the name is correct, try use this code instead
Sub SortPivotColumn()
Dim PT As PivotTable
Set PT = ActiveSheet.PivotTables("PivotTable6")
With PT
.PivotFields("Branch/Plant").Orientation = xlRowField
.PivotFields("Branch/Plant").AutoSort xlAscending, "Branch/Plant"
End With
End Sub
It had given me the desired output
Thank you!!
1 Like
no problem! good luck
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.