Do anyone know about how to merge two columns in an excel file? Any help would be much appreciated.
It depends what are you mean by “merge”?
It’s better if you provide short description of your use-case.
I want to combine column H and Column I into a single column.
Still don’t get full use-case. What is mean combine? Can you be more specific?
Column H | Column I
1 | 2 hello | world test1 | 100$ | | 01/01/2018
What result do you expect?
I am looking for a column of following type:
Both the contents should be in same column as I have shown here.
It’s not very possible in common case. Because its sometimes impossible to add together two different datatypes without transformation to common one.
You should firstly decide what data type is underneath in each column, and than use “Combine” method for this datatype or some conversion procedure to common. In your example is more like you are thinking its strings.
- Straightforward approach
Probably read range to datatable than add new column to this datatable and use some transformation in
For each row in Dt row("NewColumn") = row("Column H").ToString + " " + row("Column I").ToString Next
Than you can write it back.
What result should be here?
In mine case, there is no any data in column H and column I contains only generic values. It’s like:
Column H | Column I
Header 1 | Header 2
| Sample text
| Sample number
I want the output to be like:
Header 1 Header 2
Than you can use something like that
Use Read Range activity to read the two columns into a datatable. In your case, Range should be “H:I” and Add Headers should be unchecked. The resulting data table will have two columns with headers as Column0, Column1
Within a For Each Row activity, do this
Assign row(“Column0”) = row(“Column0”) + " " + row(“Column1”)
Assign row(“Column1”) = “”
After the For Each Row activity, use write range to write the two columns back into the excel.
In your case, Starting Cell should be “H1” and Add Headers should be unchecked