Merging two columns in excel


#1

Hi,
Do anyone know about how to merge two columns in an excel file? Any help would be much appreciated.
Thank you.


#2

Hi,
It depends what are you mean by “merge”?
It’s better if you provide short description of your use-case.


#3

Hi @Uemoe,
I want to combine column H and Column I into a single column.


#4

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?


#5

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.


#6

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.

  1. 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.


#7

What result should be here?


#8

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


#9

Than you can use something like that


#10

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