PC Review


Reply
Thread Tools Rate Thread

Combining colums in Excel

 
 
Varun
Guest
Posts: n/a
 
      24th Feb 2009
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.
 
Reply With Quote
 
 
 
 
Rick Rothstein
Guest
Posts: n/a
 
      24th Feb 2009
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.

--
Rick (MVP - Excel)


"Varun" <(E-Mail Removed)> wrote in message
news:74474E15-212C-4453-81D0-(E-Mail Removed)...
> 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.


 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Combining all rows of two colums together into one column Jim B Microsoft Excel Worksheet Functions 1 30th Sep 2009 07:38 PM
Combining 2 colums Jeremy Schubert Microsoft Excel Discussion 6 27th Feb 2009 11:17 PM
Combining Colums R.S. Microsoft Excel Misc 3 5th Feb 2008 06:11 PM
Combining Colums =?Utf-8?B?bWlrZWlub2hpbw==?= Microsoft Access Database Table Design 3 9th Feb 2007 05:32 AM
Combining data from 3 fields (colums) =?Utf-8?B?VG9tIFMu?= Microsoft Excel Misc 3 8th Apr 2004 04:15 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 09:33 PM.