How to insert a column between two columns?

excel

#1

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


#2

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,


#3

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


#4

could you please elaborate answer or share screenshot …


#5

Try this


#6

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.


#7

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

#8

A ton of thanks for you and Lucas !!!

It worked for me !!!