View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.misc
PCLIVE PCLIVE is offline
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