Hi UiPath Community,
I need an help regarding sorting a column in pivot Table.
Actually I am using Sort Table and have passed Pivot table in TableName but it is giving error.
So is there any VB code that can be used??
Hi @Kunal_Jain
Can you try the following VBA code to achieve the result:
Sub SortPivotColumn()
Dim PT As PivotTable
Set PT = ActiveSheet.PivotTables("YourPivotTableName")
With PT.PivotFields("YourColumnFieldName")
.Orientation = xlRowField
.Position = 1
.SortOnValue = True
.SortOrder = xlDescending
End With
End Sub
PS: If ascending order, change the .SortOrder as xlAscending
Hope this helps,
Best Regards.
I need to save this file with .vb extension or something else??
Hey @Kunal_Jain ,
You have to save this code in .vbs extension file and use it with Invoke VBScript activity.
Thanks,
Sanjit
1 Like
Actually I am getting this error
What should I do for it??
Hi @Kunal_Jain
Save this code in a text file with the extension .txt, them use the Invoke VBA activity to utilize the code. Provide the file’s path as input & entry method as SortPivotColumn
.
Like this:
Best Regards.
Actually in invoke VBA I think we do not provide input and output argument.