Merging duplicate coloumns in excel

Hi UiPath team,

i have an excel sheet like this


as you can see in the screenshot the coloumn expiry date comes two times the expiry dates are based on the passport and visa i need to rename the coloumn as Passport expiry date and Visa Expiry date i need final coloumn like this

please help me to find the solution

@Alan_Prakash1,

If your column sequence is fixed follow this approach

  1. Use Excel Process Scope activity, inside it use Use Excel file activity - give the excel file path
  2. Use Read cell activity to read existing value of the cell A2 into a variable for example strValue
  3. Use write cell activity to write "Passport "+ strValue at cell A2

Do same for visa as well. Just cell address will change

we cant assume the passport and visa present in fixed coloumn it may change i need a dynamic solution

@Alan_Prakash1,

Is the sequence of column going to be fixed? There should be something fixed which will identify which expiry date is of which.

i mean that in this sample excel i have given expiry date in A2 but it is not always like it may be in b2 ,c2 like that so is any way we can make it as dynamic

@Alan_Prakash1,

We can but require some reliable logic to identify it otherwise bot could be unreliable.

do u have any idea how to do this i am trying with invoke code and linq but not able to find the solution

how about using the activity “Find/Replace Value” ?
I tested your case, see the sequence in picture:

@Alan_Prakash1
by using below linq code you can serach dynamic column you will get the column index as output

(From row In dt_bankstatement.AsEnumerable(), col In dt_bankstatement.Columns.Cast(Of DataColumn)().Select(Function(c, index) New With {Key .Column = c, Key .Index = index}) Where row(col.Column).ToString().Contains(element_tosearch.Trim) Select col.Index).FirstOrDefault()

element_tosearch will be either visa or passport

cheers!!