I have multiple excel files and I’m having an issue processing them. Some of the files have columns with the same name what generates an error.
There is a way to run through all excel files and rename the repeated column?
For example, I have to columns name “description” and I want to rename the second appearance to “description_2”.
If the column is always at the same position, you can use ‘Write Cell’.
Else you can loop on your first row, read cell value and change it whenever you want
However, when I use the “Read range” activity is throws an error due to the two columns with the same name.
There is other way to loop in the first row of the excel?
But I want to do some operations and checks with the column headers (if they have spaces before or after, etc). But the files that are sent to me have columns with the same name. What I want is read the headers and do this operations, and if I found a column with the same name of a previous column in that excel file, change the name of the second one
I cannot use VBA. It was one of my first tries, but the files are in format .xlsx and .xlsb and I cannot convert them to .xlsm in order to use macros and VBA.
@joaotavares1996 Do you know the order of Columns and if so can you put the Order of new Column names in an array of Strings, In this way you can use this array of String to rename the Columns using for Each
Reads the first row (the one with column names) from input excel.
Updates the column names so that no more duplicates appear.
Overwrites the first row with the fixed column names.