Search and return messy spreadsheet for emails

Killerboy

New Member
Joined
Aug 24, 2018
Messages
1
Hi!


I have a large (6000+ rows) spreadsheet which is a mess. Its just copy/paste of dozens of different spreadsheets, containing customer information from several different stores.


Goal
My objective is to retrieve all the customer emails from the spreadsheet so we can import it to our newsletter list.


Problem
As the data comes from different vendors, the column for the customers email is varied. For example, from row 1-20 it may be that the emails are in column B. Then from 21-50 it may be in column E, as these rows are data from a different vendor.


I want to retrieve all the emails to a single column, lets say column A, for easy copy/export.


So I need a function to search the entire spreadsheet for emails, for example every cell containing the @ , and then return it to a new email column.


Any help would be greatly appreciated.
 

Excel Facts

Can you AutoAverage in Excel?
There is a drop-down next to the AutoSum symbol. Open the drop-down to choose AVERAGE, COUNT, MAX, or MIN
.
This macro will search Sheet1 / Cols A:Z / rows 1:6000 looking for the symbol @.

When located, it will copy that contents of that cell and paste on Sheet2, starting at A1 and down.

You will need to edit the sheet names if necessary and you can edit the search range as well if required.

Code:
Sub fndEmails()
  Dim rFind         As Range
  Dim sAdr          As String


  With Sheets("Sheet1").Range("A1:Z6000")
    .Select
    Set rFind = .Find(What:="*@*", _
                       After:=.Cells(.Cells.Count), _
                       LookIn:=xlValues, _
                       LookAt:=xlWhole, _
                       SearchOrder:=xlNext, _
                       MatchCase:=True)
    If Not rFind Is Nothing Then
      sAdr = rFind.Address
      Do
        Sheets("Sheet2").Cells(Rows.Count, "A").End(xlUp)(2).Value = rFind.Value2
        Set rFind = .FindNext(rFind)
      Loop While rFind.Address <> sAdr
    End If
  End With
   Sheets("Sheet1").Range("A1").Select
End Sub
 
Upvote 0

Forum statistics

Threads
1,223,903
Messages
6,175,284
Members
452,630
Latest member
OdubiYouth

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