How do I isolate all company addresses ?

Maverick27

Active Member
Joined
Sep 23, 2010
Messages
329
Office Version
  1. 2013
Platform
  1. Windows
Attn all Excel Gurus

I have an Excel sheet of 500K Email Addresses.

How do isolate all company addressess eg addresses which DON'T have the following domains ?

@Yahoo ;
@gmail ;
@Hotmail ;
@Live ;
@ymail ;
@msn

Anyone care to share a Excel function or Macro to filter out the company address domains.

Below is a screenshot of the Excel list.

Thanks in Advance.

excel.jpg
 

Excel Facts

Back into an answer in Excel
Use Data, What-If Analysis, Goal Seek to find the correct input cell value to reach a desired result
@JEC have you tried transposing 500k rows of data? Also Filter does a partial match, so it will remove something like @Livery.co.uk as well.
 
Upvote 0
Thanks for the function.

Works fine, although its gonna take some time to copy it across to 500K rows.
Excel Formula:
 IF(ISNUMBER(SEARCH("@Yahoo",A2)),"Needs to be excluded",IF(ISNUMBER(SEARCH("@Gmail",A2)),"Needs to be excluded",IF(ISNUMBER(SEARCH("@Hotmail",A2)),"Needs to be excluded",IF(ISNUMBER(SEARCH("@Live",A2)),"Needs to be excluded",IF(ISNUMBER(SEARCH("@ymail",A2)),"Needs to be excluded",IF(ISNUMBER(SEARCH("@msn",A2)),"Needs to be excluded","Include"))))))

I think this should work but may potentially be very slow calculating your sheet given the size of the workbook.

There is probably a better approach to this.
 
Upvote 0
Or

VBA Code:
Sub jec()
 With Range("A1", Range("A" & Rows.Count).End(xlUp))
   .AutoFilter 1, Filter(Filter(Filter(Filter(Filter(Filter(Application.Transpose(.Value), "@Yahoo", 0, 1), "@Gmail", 0, 1), "@Hotmail", 0, 1), "@Live", 0, 1), "@ymail", 0, 1), "@msn", 0, 1), 7
 End With
End Sub
Thanks for sharing.

The code works like a charm.
 
Upvote 0
How about
VBA Code:
Sub Maverick()
   Dim Ary As Variant, Nary As Variant, Sp As Variant
   Dim Lst As String
   Dim r As Long, nr As Long
  
   Lst = "|Yahoo|gmail|Hotmail|Live|ymail|msn"
   Ary = Range("A2", Range("A" & Rows.Count).End(xlUp)).Value2
   ReDim Nary(1 To UBound(Ary), 1 To 1)
   With CreateObject("scripting.dictionary")
      For r = 1 To UBound(Ary)
         Sp = Split(Split(Ary(r, 1), "@")(1), ".")(0)
         If InStr(1, Lst, "|" & Sp & "|", vbTextCompare) = 0 Then
            If Not .Exists(Sp) Then
               nr = nr + 1
               Nary(nr, 1) = Sp
               .Add Sp, Nothing
            End If
         End If
      Next r
   End With
   Range("B2").Resize(nr).Value = nr
End Sub
Sorry - the macro code is giving an Error.

mave-err.jpg
 
Upvote 0
How about
VBA Code:
Sub test()
    Dim a, b
    Dim i, k
    k = 1
    a = Sheets("sheet1").Cells(2, 1).Resize(Sheets("sheet1").Cells(Rows.Count, 1).End(xlUp).Row - 1)
    ReDim b(1 To UBound(a))
    With CreateObject("VBScript.RegExp")
        .Pattern = "@yahoo|@gmail|@hotmail|@live|@ymail|@msn"
        .IgnoreCase = True
        For i = 1 To UBound(a)
            If .test(a(i, 1)) Then
                b(k) = a(i, 1)
                k = k + 1
            End If
        Next
    End With
    Sheets("sheet1").Cells(2, 2).Resize(k - 1) = Application.Transpose(b)
End Sub

Sorry - the code is giving an Error.
test-err.jpg
 
Upvote 0
@Fluff, I tried on 500k rows and it worked. Transposing to a variable could be different than to the worksheet, which will give issues after 16k rows sometimes...
 
Upvote 0
Transposing to a variable could be different than to the worksheet,
If it works, then maybe it is just writing to the sheet that's a problem, I always thought it was the Transpose itself that couldn't handle that much data, but obviously wrong.
 
Upvote 0

Forum statistics

Threads
1,215,043
Messages
6,122,812
Members
449,095
Latest member
m_smith_solihull

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