Delete multiple CSV or Excel columns and column range

Hi. I have to delete multiple columns and column range at once.
For example I need to delete columns AC, CM, CO, CQ, CS and column range DV:EA. Can someone provide me correct invoke code or any other fast solution? I don’t have column names/headers.

Hi @markosc

Do you want to delete in datatable or excel file… thanks

Doesn’t matter

Also, I don’t have column names, only index

Hi @markosc ,

Here is the package called BalaReva.EasyExcel.Activities.

  • It has an activity called “Get Column Name”. using this you can able to get the column name for the index.
  • Another activity called “Delete Columns”. You can delete the multiple columns in a single execution like below image.

Check this video :

Regards
Balamurugan.S

Can’t use new packages. Thanky anyway

1 Like

You can use invoke VBA activity for this,

Do this one time on excel,

In order for this activity to work, Trust Access to the VBA project object model must be enabled from Excel (File > Options > Trust Center > Trust Center Settings > Macro Settings > Select the Trust Access to the VBA project object model check box).

Put the code on text file,

Sub macro()

Range(“AC1”).entirecolumn.delete
Range(“CM1”).entirecolumn.delete
Range(“CO1”).entirecolumn.delete
Range(“CQ1”).entirecolumn.delete
Range(“CS1”).entirecolumn.delete
Range(“DV1:EA1”).entirecolumn.delete

End sub

In the code file path give the text file path
In method name give macro

Thanks

1 Like

It worked, thanks!

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.