Hi,
Do anyone know about how to merge two columns in an excel file? Any help would be much appreciated.
Thank you.
Hi,
It depends what are you mean by “merge”?
It’s better if you provide short description of your use-case.
Hi @Uemoe,
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?
Hi,
I am looking for a column of following type:
1 2
hello world
test1
100$
01/01/2018
Both the contents should be in same column as I have shown here.
Thank you.
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?
Hi,
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:
Column H
Header 1 Header 2
Sample text
Sample number
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
But within a for each row activity it is giving error
Assign: Exception has been thrown by the target of an invocation.
Becuase
If that assign is used in a for each or for each row loop and if the TO property variable is from that loop then it will show
Like if we are trying to modify a element or delete a element from the variable that the loop is iterating with then we will face this issue