Hi guys!
I have a long list (16000 words) that contains plenty of words along a column (A) that I need to sort through and delete duplicates.
It looks like this: (words are column A, Cell addresses column B and worksheet names (Home, Page 2 and Order) are column C
rock,$B$3,Home
money,$B$4,Home
sleep,$B$6,Home
blue,$B$7,Home
rock,$B$8,Home
honey,$D$8,Home
eat,$D$9,Home
read,$D$10,Home
rock,$E$13,Home
beard,$E$14,Page 2
woman,$E$15,Page 2
rock,$D$16,Page 2
honey,$E$16,Page 2
clean,$C$18,Page 2
sleep,$E$18,Page 2
rock,$G$18,Order
beard,$I$18,Order
band,$K$18,Order
camp,$M$18,Order
I need it to show up like this... (Commas denote cell breaks) (The # sign is to let another macro know the difference between cell address and worksheet)
rock,$B$3#Home,$B$8#Home,$E$13#Home,$D$16#Page 2,$G$18#Order
money,$B$4#Home
sleep,$B$6#Home,$E$18#Page 2 ...etc
I already have some code that I was playing with attached but I can't seem to get it to work.
Can anyone help me?
Thanks!
Sar
You definately do NOT want to be merging cells!' this should do what you want provided your data is laid out as in the example, change the sheet names to suit:
Sub find_and_concatenate() '** code supplied by Simon Lloyd ** '** 02/09/2010 ** '** http://www.thecodecage.com ** Dim c As Range, FirstAddress As String Dim MyCell As Range, Rng As Range Dim i As Long, r As Long r = 0 Set Rng = Sheets("Sheet1").Range("A1:A" & Sheets("Sheet1").Range("A" & Rows.Count).End(xlUp).Row) For Each MyCell In Rng If Application.WorksheetFunction.CountIf(Sheets("Sheet1").Range("E1:E" _ & Sheets("Sheet1").Range("E" & Rows.Count).End(xlUp).Row), MyCell.Value) >= 1 Then GoTo Nxt If MyCell.Row = 1 Then GoTo N1 With Rng Set c = .find(MyCell, LookIn:=xlValues) If Not c Is Nothing Then Sheets("Sheet1").Range("E" & Rows.Count).End(xlUp).Offset(r, 0) = c.Value Sheets("Sheet1").Range("F" & Rows.Count).End(xlUp).Offset(r, 0) = c.Offset(0, 1) & "#" & c.Offset(0, 2) FirstAddress = c.Address i = 1 Do Set c = .FindNext(c) If c.Address <> FirstAddress Then Sheets("Sheet1").Range("F" & Rows.Count).End(xlUp).Offset(0, i) = c.Offset(0, 1) & "#" & c.Offset(0, 2) i = i + 1 End If Loop While Not c Is Nothing And c.Address <> FirstAddress End If End With Nxt: r = 1 N1: Next MyCell End Sub
Not all forums are the same - seek and you shall find
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks