Check column name if found header same

I have excel file but some name column have same —> I want change name that same by add 2 as below.

Please guide me about it.

Hi @fairymemay

Please try using.

DataTable.Columns(“columnName”).ColumnName= ‘XYZ’


DataTable.Columns(Column Index).ColumnName= ‘XYZ’

Please follow the below steps as its having duplicate column so we can’t store it in datatable.

1.Use Read Range Acivity and uncheck “AddHeaders” in property panel and store in datatable
2.Now remove first row using remove datarow activity.
3.Rename all column using datatable.Columns(index).ColumnName= ‘Your columnName’

Hi @fairymemay ,

Could you try this?


Declare an Array of String
Assign →

arr_ColNames = dt_sampleData.Columns.Cast(Of DataColumn).Select(Function(s) s.ColumnName).ToArray()
(From row In dt_sampleData.AsEnumerable()
Let ls = row.ItemArray.ToList()
Let ra = ls.ConvertAll(Function(a) If(arr_ColNames.Contains(a.ToString), a.ToString+"2",a.ToString)).ToArray()
Select dt_result.Rows.Add(ra)).CopyToDataTable()

ReplaceColumnNamesInRow.xaml (7.8 KB)

Kind Regards,
Ashwin A.K


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