Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
UB UB is offline
external usenet poster
 
Posts: 120
Default Combine 2 columns using VBA

Hi
I have data in approx 800 lines as:Column A Column B
Cook Mark
Jones Peter

Column A has last name, Column B has first name.
I want to joing data of 2 columns to show Firstname Lastname in ColumnA and
then delete Column B

Please advise how to write this code
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,124
Default Combine 2 columns using VBA

For each c in range("a2"a800")
c.value= c & " " & c.offset(,1)
next c
columns(2).delete

--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"ub" wrote in message
...
Hi
I have data in approx 800 lines as:Column A Column B
Cook Mark
Jones Peter

Column A has last name, Column B has first name.
I want to joing data of 2 columns to show Firstname Lastname in ColumnA
and
then delete Column B

Please advise how to write this code


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 71
Default Combine 2 columns using VBA

You can do without code. Use the formula

=A1 & " " & B1

in column C and copy down. Then copy the formula cells and do an edit,
paste special values back over the formulas. Then delete columns A and B

Robert Flanagan
http://www.add-ins.com
Productivity add-ins and downloadable books on VB macros for Excel

"ub" wrote in message
...
Hi
I have data in approx 800 lines as:Column A Column B
Cook Mark
Jones Peter

Column A has last name, Column B has first name.
I want to joing data of 2 columns to show Firstname Lastname in ColumnA
and
then delete Column B

Please advise how to write this code



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,501
Default Combine 2 columns using VBA

Hi,

Right click your sheet tab, view code and paste this in and run it.

Sub sonic()
lastrow = Cells(Cells.Rows.Count, "A").End(xlUp).Row
Set MyRange = Range("A1:A" & lastrow)
For Each c In MyRange
c.Value = c.Offset(, 1).Value & " " & c.Value
Next
Columns(2).ClearContents
End Sub

Mike

"ub" wrote:

Hi
I have data in approx 800 lines as:Column A Column B
Cook Mark
Jones Peter

Column A has last name, Column B has first name.
I want to joing data of 2 columns to show Firstname Lastname in ColumnA and
then delete Column B

Please advise how to write this code

  #5   Report Post  
Posted to microsoft.public.excel.programming
UB UB is offline
external usenet poster
 
Posts: 120
Default Combine 2 columns using VBA

Thanks , it works


"Mike H" wrote:

Hi,

Right click your sheet tab, view code and paste this in and run it.

Sub sonic()
lastrow = Cells(Cells.Rows.Count, "A").End(xlUp).Row
Set MyRange = Range("A1:A" & lastrow)
For Each c In MyRange
c.Value = c.Offset(, 1).Value & " " & c.Value
Next
Columns(2).ClearContents
End Sub

Mike

"ub" wrote:

Hi
I have data in approx 800 lines as:Column A Column B
Cook Mark
Jones Peter

Column A has last name, Column B has first name.
I want to joing data of 2 columns to show Firstname Lastname in ColumnA and
then delete Column B

Please advise how to write this code

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
combine columns Darrell_Sarrasin via OfficeKB.com Excel Discussion (Misc queries) 7 September 24th 08 07:45 PM
Combine multiple columns into two long columns, Repeating rows in first column [email protected] Excel Discussion (Misc queries) 2 July 31st 06 09:45 PM
Combine multiple columns into two long columns, Repeating rows in first column [email protected] Excel Discussion (Misc queries) 0 July 31st 06 05:07 PM
I need to combine 30 columns into 1 or 2 Linda Excel Worksheet Functions 1 November 5th 05 02:02 PM
How to combine two columns? Robert Judge Excel Worksheet Functions 1 May 23rd 05 06:54 PM


All times are GMT +1. The time now is 06:05 PM.

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"