Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 37
Default Combining colums in Excel

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.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,934
Default Combining colums in Excel

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" wrote in message
...
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
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Combining all rows of two colums together into one column Jim B[_2_] Excel Worksheet Functions 1 September 30th 09 07:38 PM
Combining Colums R.S. Excel Discussion (Misc queries) 3 February 5th 08 06:11 PM
In Excel the colums which used to be A,B,C D etc are now 1,2,3 Dave Lock Excel Discussion (Misc queries) 3 May 9th 06 03:16 PM
Combining workshhets with different number of colums and column wi TX DPS Excel Discussion (Misc queries) 1 August 13th 05 05:12 AM
How do I name my colums in Excel ? Kath New Users to Excel 1 February 3rd 05 01:00 AM


All times are GMT +1. The time now is 04:11 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"