How to delete columns by name in Excel?

Hi All,

I would like to delete a specific column in Excel, so I tried to use the activity “Delete Column”, however, it looks like that it does not recognize the Excel file.

How can I accomplish it?

  • Excel file name: “Test.xlsx”
  • Sheet Name: “Sheet2”
  • Column Name: “ColumnB”

Thanks!

Why don’t you format the range as a table using the activity. After that you will be able to identify the columns using the field names in that range.

There should be a ‘Format as table’ activity in UiPath itself and you can give that table your own name. The 1st row in the range will become the header and then you can select the fields you want to delete.

UiPath by default recognizes the range using the column names by the header fields and not the column numbers as you want to.

I can’t find any activity with the name “Format as Range”, I can only install “Official uiPath Sources” :frowning:

Hi,

Can you try Filter DataTable activity?
We can remove specific columns at Output Columns tab.

img20201116-4

Regards,

4 Likes

checking…

Hi,

If you want to directly remove columns of the sheet, can you try Insert/Remove columns activity?

Regards,

2 Likes

I tried that option but it requires a start “position”, however in this case I need to delete columns in different positions…I’m currently trying to use your first recommendation “Filter”

I am not sure if you the terminology is the same. But it should be an activity under excel to convert a range into a table. I use studioX version of UiPath The activity name I get is “Format as table”. It is part of the official package of excel activities itself

Here is the snapshot

@Tana20 - Here you go…

xaml image :

Input: image

Output: image

You can see the first column is deleted.

You need below packages for these…

image

however in this case I need to delete columns in different positions… You can delete any columns by range or specifically image . Don’t forgot to add quotes.

Please mark this as solution, if it solves your query.

2 Likes

@Yoichi
Thanks! I have been able to remove all the unnecessary columns using this activity. :partying_face:

2 Likes

I cannot use unofficial activities :frowning:

1 Like

@Tana20 - no problem. So next time, when you post a query please clearly state that “I cannot use any unofficial package”, this will help the ones who are trying to provide solutions.

1 Like

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