How to insert a column between two columns?

How to insert a column between two columns in excel using activities without using send hotkey ?

Hello!

You can use “Read Range” activity to read all the content and fill a DataTable. After this, you can use “datatable.Columns(ColumnName).SetOrdinal(columnPosition)”

Example:

image

It will move the column “NewColumn” to position 3.

Hope It Helps :wink:

Regards,

4 Likes

Thanks for your reply
but it is giving error as expression doesn’t produce a value.

could you please elaborate answer or share screenshot …

Try this

Thanks for your reply Akshay. In the above link you are trying to modify the data table(swapping columns).But I want to insert the new column in 2nd index.

add column to datatable and then use invoke method activity to set ordinal of the column as in example.

It is not possible set ordinal while inserting a column.

  1. insert column
  2. set ordinal of column

A ton of thanks for you and Lucas !!!

It worked for me !!!

2 Likes

Could you please tell the target type, target object and method name you selected that worked?

the answer to this question is in the ff. link . just sharing for future readers.

2 Likes

But this is not working for me it iUntitled s Showing bellow error, will you please help me in it.

Try to use the same command but inside the “Invoke code” Activity :slight_smile:

1 Like