CONCATENATE two columns into one row

tytrogdon987

New Member
Joined
Dec 15, 2016
Messages
3
I have two columns in which I need to concatenate the data from each column alternately into one cell.

Column A
Column B
12
OR
34
OR
56
OR
78
OR
90
OR

<tbody>
</tbody>

Expected result: 12OR34OR56OR78OR90

There are over 1000 rows per column and I am having a hard time finding an efficient way to use concatenate if that is even the best way to approach this problem.

Your help is greatly appreciated!
 

Excel Facts

Select all contiguous cells
Pressing Ctrl+* (asterisk) will select the "current region" - all contiguous cells in all directions.

Rick Rothstein

MrExcel MVP
Joined
Apr 18, 2011
Messages
38,154
Office Version
  1. 2019
  2. 2010
Platform
  1. Windows
Will Column B always have the same text in every cell as your example shows?
 
Upvote 0

Rick Rothstein

MrExcel MVP
Joined
Apr 18, 2011
Messages
38,154
Office Version
  1. 2019
  2. 2010
Platform
  1. Windows
Yes it will.
Okay, that simplifies thing a little. Give this UDF (user defined function) a try...
Code:
[table="width: 500"]
[tr]
	[td]Function ConcatAandB() As String
  ConcatAandB = Replace(Trim(Join(Application.Transpose(Range("A1", Cells(Rows.Count, "A").End(xlUp))))), " ", Range("B1"))
End Function[/td]
[/tr]
[/table]

HOW TO INSTALL UDFs
------------------------------------
If you are new to UDFs, they are easy to install and use. To install it, simply press ALT+F11 to go into the VB editor and, once there, click Insert/Module on its menu bar, then copy/paste the above code into the code window that just opened up. That's it.... you are done. You can now use ConcatAandB just like it was a built-in Excel function. For example,

=ConcatAandB()

If you are using XL2007 or above, make sure you save your file as an "Excel Macro-Enabled Workbook (*.xlsm) and answer the "do you want to enable macros" question as "yes" or "OK" (depending on the button label for your version of Excel) the next time you open your workbook.
 
Last edited:
Upvote 0

Anand Sharma

Board Regular
Joined
Nov 22, 2016
Messages
63
Hi

You can use array formula here , assuming that your second column will always have "OR"

try below
=transpose(concatenate(A2:A6,"OR"))

Press F9 and Enter
 
Last edited:
Upvote 0

Forum statistics

Threads
1,195,960
Messages
6,012,566
Members
441,710
Latest member
needhelp_please

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top