Sample Visual Basic Procedure
Do While ActiveCell <> "" 'Loops until the active cell is blank.
'The "&" must have a space on both sides or it will be
'treated as a variable type of long integer.
ActiveCell.Offset(0, 1).FormulaR1C1 = _
ActiveCell.Offset(0, -1) & " " & ActiveCell.Offset(0, 0)
NOTE: The statement ActiveCell.Offset(0, 1).FormulaR1C1 can be replaced with the statement ActiveCell.Offset(0, 1).Formula. They can be used with equal success if you are using text and numbers only (not formulas). The R1C1 used at the end of the first statement refers to row one, column one and is the form used in examples in Help.
To Use the Macro in Microsoft Excel
- Open the workbook which contains the data.
- Press ALT+F11 to activate the Visual Basic Editor.
- Click Module on the Insert menu to insert a module. Type the macro above in the module's code window.
- Click Close and Return to Microsoft Excel on the File menu.
- Select the worksheet that contains the data that you want to concatenate.
- Click the top cell in the right-hand column of data that you want to concatenate. For example, if cells A1:A100 and B1:B100 contain data, click cell B1.
- Point to Macros on the Tools menu and click Macro. Select the ConcatColumns macro, and click Run.
Article ID: 113237 - Last Review: Jan 7, 2017 - Revision: 1