MrExcel Publishing
Your One Stop for Excel Tips & Solutions

Use a Macro to append one cell onto another


Posted by Dave Blindt on November 12, 2001 11:32 AM

I need to make a Macro that will select the text in one cell and append it onto the text in another cell.

I can then step thru the entire worksheet and merge 2 columns of cell infromation.


Posted by Barrie Davidson on November 12, 2001 11:46 AM

Can you use a formula to combine the cells? Something like

=A1&B1

which will combine the contents of cell A1 and cell B1. Is this an option for you?

BarrieBarrie Davidson

Posted by Dave Blindt on November 12, 2001 12:16 PM

Thanks for the idea, but that would requires that I keep the original column intact. I was looking for a macro copy and paste command.
Dave

Posted by Barrie Davidson on November 12, 2001 12:50 PM

Okay, how about this macro which will combine columns A and B.

Sub CombineColumns()
' Written by Barrie Davidson

Range("C1", Range("A65536").End(xlUp).Offset(0, 2).Address).FormulaR1C1 = "=RC[-2]&RC[-1]"
Range("C1", Range("C65536").End(xlUp).Address).Copy
Range("C1", Range("C65536").End(xlUp).Address).PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:= _
False, Transpose:=False
Application.CutCopyMode = False
ActiveCell.Select
End Sub


BarrieBarrie Davidson

Posted by Dave Blindt on November 12, 2001 1:11 PM

Thanks