Excel column operation

  • let say i have n number of columns let say column A, column B and so on and from that I want to search for particular word let say that word “Week 1” is present in column B.

  • once i get that so before that column B. want to add or insert new column.

  • any help
    thanks advanced

1 Like

Hi @Mayur_Pawar
Use read range
and use for each row in Datatable
if row(“Column B”).ToString.Contains(“Week1”)

use insert delete columns activity give the index value as -1 and then add column

Ashwin S

@AshwinS2 my column will not be same every time like everytime its not like column B its just example if any column has variable “week 1” so before that i want to insert column

Hi @Mayur_Pawar

then before condition uise Insert/Delete Column and then check the conditions

Ashwin S

Hi @Mayur_Pawar

  • Read the excel as datatable lets assume ‘dt’
  • Use for each row to loop the table
  • Declare a variable as int datatype, lets called ‘ordinal’
  • inside loop assign as
    ordinal = Array.FindIndex(row.ItemArray, Function(c) c.ToString().Contains("Week 1"))
  • And add invoke code activity, send argument as ‘dt’ as in/out and ‘ordinal’ as in
  • Add the below code in the invoke code activity
    dt.Columns.Add("Column C", GetType(String)).SetOrdinal(ordinal-1)
1 Like

Hi @Mayur_Pawar,

To search the value in Excel.

It returns the Cell info. Using this you can read cell value from excel.