Sort, dedupe, merge and format in excel

parfm

New Member
Joined
Dec 14, 2009
Messages
2
I need to send out a holiday email to our clients and have all their data in excel. Simple enough, but I need to create a field/column that shows who in my company the email is from taking into account that in most cases each contact needs to have more than one person appearing in the “from” field/column.<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:eek:ffice:eek:ffice" /><o:p></o:p>
<o:p></o:p>
I’ve sorted the data by contact, so now many contacts are on multiple lines and I need to merge people in the “from” column into one cell for that owner and separate them with a comma and then delete the duplicate rows.

For example:


<o:p></o:p>
<o:p></o:p>

Any help would be great!<o:p></o:p>
Matt<o:p></o:p>
 

Excel Facts

Links? Where??
If Excel says you have links but you can't find them, go to Formulas, Name Manager. Look for old links to dead workbooks & delete.
Welcome to the board!

I'm sure there are many more elegant ways to do this, but here's a quick way (first sort your data by email address if it's not already):

Excel Workbook
ABCDEF
1First NameLast NameEmailFromConcatRevSort
2JohnDoejohn@doe.comPeterPeter1
3JohnDoejohn@doe.comJanePeter, Jane2
4JohnDoejohn@doe.comPaulPeter, Jane, Paul3
5JohnDoejohn@doe.comSarahPeter, Jane, Paul, Sarah4
6TaiGovindatai@govinda.comPeterPeter5
7TaiGovindatai@govinda.comJanePeter, Jane6
8TaiGovindatai@govinda.comPaulPeter, Jane, Paul7
9TaiGovindatai@govinda.comSarahPeter, Jane, Paul, Sarah8
Sheet1
Excel 2003
Cell Formulas
RangeFormula
E2=IF(C2=C1,E1&", "&D2,D2)



...Paste down the formula in column E, then paste values over the result. Then sort descending by column F and use "Remove Duplicates" from the Data ribbon in order to remove all but the top-most instance of each email address (within Remove Duplicates, check only Email Address).
 
Upvote 0
Hi, An Alternative, Results start "F2".

Code:
[COLOR=navy]Sub[/COLOR] MG14Dec46
[COLOR=navy]Dim[/COLOR] Rng [COLOR=navy]As[/COLOR] Range, Dn [COLOR=navy]As[/COLOR] Range, n [COLOR=navy]As[/COLOR] [COLOR=navy]Long,[/COLOR] Twn [COLOR=navy]As[/COLOR] [COLOR=navy]String,[/COLOR] Q
[COLOR=navy]Set[/COLOR] Rng = Range(Range("A1"), Range("A" & Rows.Count).End(xlUp))
    ReDim ray(1 To Rng.Count, 1 To 4)
        [COLOR=navy]With[/COLOR] CreateObject("scripting.dictionary")
            .CompareMode = vbTextCompare
    [COLOR=navy]For[/COLOR] [COLOR=navy]Each[/COLOR] Dn [COLOR=navy]In[/COLOR] Rng
        Twn = Dn & Dn.Next
            [COLOR=navy]If[/COLOR] Not .Exists(Twn) [COLOR=navy]Then[/COLOR]
                n = n + 1
                .Add Twn, Array(n, 1)
                ray(n, 1) = Dn: ray(n, 2) = Dn.Item(1, 2)
                ray(n, 3) = Dn.Item(1, 3): ray(n, 4) = Dn.Item(1, 4) & ","
            [COLOR=navy]Else[/COLOR]
                Q = .Item(Twn)
                Q(1) = Q(1) + 1
                ray(Q(0), 4) = ray(Q(0), 4) & Dn.Item(1, 4) & ","
                .Item(Twn) = Q
[COLOR=navy]           End[/COLOR] If
[COLOR=navy]   Next[/COLOR]
Range("F2").Resize(.Count, 4) = ray
[COLOR=navy]End[/COLOR] [COLOR=navy]With[/COLOR]
[COLOR=navy]End[/COLOR] [COLOR=navy]Sub[/COLOR]
Regards Mick
 
Upvote 0
Sorry to resurrect an old thread guys but I have a similar scenario which I am hoping you can help me with, see below:


CURRENT STATE OF DATA:
First NameLast NameEmailsOption 1Option 2Option 3
JohnDoejohndoe@abc.comx
JohnDoejohndoe@abc.comx
JohnDoejohndoe@abc.comx
Desired Data:
First NameLast NameEmailsOption 1Option 2Option 3
JohnDoejohndoe@abc.comxxx

<colgroup><col><col><col><col span="3"></colgroup><tbody>
</tbody>
 
Upvote 0

Forum statistics

Threads
1,214,965
Messages
6,122,495
Members
449,088
Latest member
Melvetica

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top