Solved

distribution list

Posted on 2014-09-05
9
158 Views
Last Modified: 2014-09-14
Hi,

I have a distribution list which i must de-dupe

So in one row i have

xyz@abc.com, abc@xyz.com, bcd@xyz.com

next row

ytr@xyz.com, abc@xyz.com

Note that abc@xyz.com is contained in both rows, i need some code that will delete any dupes, so that there is only one abc@xyz.com


I have 184 rows of names that it would need to loop through

Many thanks
0
Comment
Question by:Seamus2626
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 2
  • 2
9 Comments
 
LVL 12

Expert Comment

by:James Elliott
ID: 40305911
Do the names need to remain in rows, seperated by commas, or can be transpose the lot into a one-per-line-list?
0
 

Author Comment

by:Seamus2626
ID: 40305923
Lines dont have to remain in rows, as the end game is to paste into an email

Thanks Jell
0
 
LVL 27

Assisted Solution

by:Glenn Ray
Glenn Ray earned 250 total points
ID: 40305967
Here's the quickest way, especially if this is a one-time event:

1) In Excel, select all cells in this column and copy
2) Open Word
3) Paste the values in Word
4) So a search and replace to convert the commas into paragraph marks:
search and replaceBe sure to add a space after the comma to remove leading spaces.  You'll see this:
results5) Copy all the converted text.
6) Switch back to Excel and open a blank sheet
7) Paste the values in cell A1
8) Menu:  Data tab, "Remove Duplicates"

That will leave you with just the unique email addresses.

Regards,
-Glenn
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 12

Accepted Solution

by:
James Elliott earned 250 total points
ID: 40305983
Try this (in a new module). It assumes all emails are in column A. It puts results in column B.

Option Explicit

Sub EE()

Dim ws As Worksheet
Dim LR As Long
Dim x As Long, y As Long, i As Long
Dim var As Variant
Dim arr() As Variant

Set ws = Sheets(1)
LR = ws.Range("A" & Rows.Count).End(xlUp).Row

ws.Range("B:B").Clear

For x = LR To 1 Step -1

    var = Split(ws.Cells(x, 1), ",")
    
        For y = LBound(var) To UBound(var)
        
            If Not InArr(var(y), arr) Then
            
                ReDim Preserve arr(i)
                arr(UBound(arr)) = Trim(var(y))
                i = i + 1
                
            End If
            
        Next y
Next x

ws.Range("B1").Resize(UBound(arr) + 1, 1).Value = Application.Transpose(arr)

Set var = Nothing
Set ws = Nothing

End Sub

Public Function InArr(p As Variant, arr As Variant) As Boolean

    Dim x As Long
    
        If Not IsArray(arr) Then Exit Function
        
        On Error GoTo err_handler
        
        For x = LBound(arr) To UBound(arr)
        
        
            If UCase(Trim(arr(x))) = UCase(Trim(p)) Then
            
                InArr = True
                Exit Function
            
            End If
            
        Next x
        
err_handler:
 
 Err.Clear
 
End Function

Open in new window

0
 

Assisted Solution

by:Seamus2626
Seamus2626 earned 0 total points
ID: 40305997
Thanks!
0
 
LVL 27

Expert Comment

by:Glenn Ray
ID: 40306000
You're welcome.  I routinely do this similar method for email distribution also.

-Glenn
0
 

Author Comment

by:Seamus2626
ID: 40306004
Jell, thats lovely code, sorry i assigned the pointst too early, il re-open and split, thanks
0
 

Author Closing Comment

by:Seamus2626
ID: 40321503
Thanks all
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Excel VBA Workbook - Change hours 2 41
Excel - Lookup tarif based on weight and Zone 5 35
Vlookup Help 3 27
Embed XL WS and Objects into a PPTX 8 33
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
This article will guide you to convert a grid from a picture into Excel format using Microsoft OneNote and no other 3rd party application.
This Micro Tutorial will demonstrate in Google Sheets how to use the HYPERLINK function to create live links inside your spreadsheet.
This Micro Tutorial will demonstrate how to create pivot charts out of a data set. I also added a drop-down menu which allows to choose from different categories in the data set and the chart will automatically update.

739 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question