Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 168
Default Combining data from two columns

Here's some code you might be able to use.



Range("A1:" & Range("A65536").End(xlUp).Address).Select
Selection.Copy

Range("C1").Select
ActiveSheet.Paste

Range("B1:" & Range("B65536").End(xlUp).Address).Select
Selection.Copy

Range("C65536").End(xlUp).Select
ActiveSheet.Paste

'If you want to remove duplicate names or entries, use this code
' This function must sort first.
Range("C1:" & (Range("C65536").End(xlUp).Address)).Select
Selection.Sort Key1:=Range("C1"), Order1:=xlAscending,
Header:=xlNo, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom
ColNum = Selection(1).Column
For RowNdx = Selection(Selection.Cells.Count).Row To _
Selection(1).Row + 1 Step -1
If Cells(RowNdx, ColNum).Value = Cells(RowNdx - 1, ColNum).Value
Then
Cells(RowNdx, ColNum).Value = ""
End If
Next RowNdx

Selection.Sort Key1:=Range("C1"), Order1:=xlAscending, Header:=xlNo, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom

'End Remove Duplicates



If you want it to update when the worksheet is changed, right-click on that
worksheet and select View code.
Click General dropdown and select Worksheet. Click other dropdown and
select Change. Then enter the code above.

HTH,
Paul





"dziw" wrote in message
...

Thanks, but I wasn't clear. Each column is a separate category of names,
so I'm not combining each cell (i.e. first & last), but am making a new
longer column combining all the names from each column.


--
dziw
------------------------------------------------------------------------
dziw's Profile:
http://www.excelforum.com/member.php...o&userid=10422
View this thread: http://www.excelforum.com/showthread...hreadid=567563



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
Macro question Chris Excel Worksheet Functions 12 July 7th 06 01:23 AM
ranking query JaimeTimbrell Excel Discussion (Misc queries) 2 February 16th 06 08:09 AM
combining 2 columns of data Miss Dedly Excel Discussion (Misc queries) 1 January 12th 06 07:14 PM
Inserting a new line when external data changes Rental Man Excel Discussion (Misc queries) 0 January 11th 06 07:05 PM
Pulling data from 1 sheet to another Dave1155 Excel Worksheet Functions 1 January 12th 05 05:55 PM


All times are GMT +1. The time now is 07:04 PM.

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

About Us

"It's about Microsoft Excel"