Combining colums in Excel

  • Thread starter Thread starter Varun
  • Start date Start date
V

Varun

Hi,

I'd like to know how to take the text from cells in column B and "append" it
to the text contained in column A. For example, here's what I have:

Col A Col B
good bad
boy girl
uncle aunt

I'd like to modified Col A as below:

Col A
goodbad
boygirl
uncleaunt

How can I do this? I tried to do this by writing the code below but that
doesn't work since it's recursive.

Worksheets("Temp3").Cells(startrow1, 4).Value =
Worksheets("Temp3").Cells(startrow1, 4).Value & _
Worksheets("Temp3").Cells(startrow1, 4).Value & ","

Thanks for help.
 
Give this macro a try...

Sub CombineAandB()
Dim X As Long
Dim LastRow As Long
Const StartRow As Long = 2
With Worksheets("sheet 3")
LastRow = .Cells(.Rows.Count, "A").End(xlUp).Row
For X = StartRow To LastRow
.Cells(X, "A").Value = .Cells(X, "A").Value & .Cells(X, "B").Value
Next
' Comment the following line out if you don't
' want to delete the contents of Column B
.Range("B" & StartRow & ":B" & LastRow).Clear
End With
End Sub

And note the commented line inside the code.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top