How can I delete column from Pivot Table

Is there an official UiPath activity for deleting a column from a pivot table?

Using the delete column activity I get an error message that the column cannot be deleted because it is a part of a pivot table.

If there isn’t a specific activity, how can this be achieved with the official UiPath excel activities.

Hi @M_Kr

You can try with excel macros

You need to save this macro in a notepad and save as filename.vb

Static macro

Option Explicit
Sub Macro1()
'
' Macro1 Macro
'

'
    ActiveSheet.PivotTables("Your Pivot table name").PivotFields("your column name"). _
        Orientation = xlHidden
End Sub

Dynamic Macro

you need to give the column name in the invoke vba actvity parameter

Option Explicit
Sub Macro1(ColumnName As String)
'
' Macro1 Macro
'

'
    ActiveSheet.PivotTables("PivotTable1").PivotFields(ColumnName). _
        Orientation = xlHidden
End Sub

Regards
Sudharsan

If you need to use the macro to the dynamic files you need to save above macro in a notepad and save as filename.vb

and call the excel application scope

Regards
Sudharsan

Hi @Sudharsan_Ka

Thank you so much for your recommendation.

Unfortunately I don’t believe I can use macros, since in order to use them I have to ‘enable macros’ in excel, and it seams like it can cause security issues.

Is this the only way this can be done?

Thank you once again!

No @M_Kr

You dont need to enable macro in the excel what you need to do is


Enable trust access to the VBAobject model

And add the location of that specific file in trusted location

Regards
Sudharsan

I will research how secure this solution is and get back to you.

Edit: Unfortunately I don’t believe I will be able to do this. Thank you for your suggestion though.