Tip: Other languages are Google-Translated. You can visit the English version of this link.
Log in
x
or
x
x
Register
x

or

How to quickly extract email address from text string?

When you import some email addresses form Website to Excel worksheet, there always contains irrelevant text, but now you just want to extract the pure email addresses from the text string (see following screenshots). How could you quickly only get the email addresses from the cell text?

doc-extract-emails1 -2 doc-extract-emails2

Extract email address from text string with Formula

Extract email address from text string with User Defined Function

Extract email address from text string with VBA code

Extract email address from text string with Kutools for Excel


Extract Email Addresses from text strings:

Kutools for Excel’s Extract Email Address can help you extract the email addresses from the text strings quickly and conveniently.

doc extract emails-1

Kutools for Excel: with more than 200 handy Excel add-ins, free to try with no limitation in 60 days. Download and free trial Now!


arrow blue right bubble Extract email address from text string with Formula


Here I introduce you a long formula to extract only the email addresses from the text in Excel. Please do as follows:

1. In the adjacent cell B1, enter this formula =TRIM(RIGHT(SUBSTITUTE(LEFT(A1,FIND (" ",A1&" ",FIND("@",A1))-1)," ", REPT(" ",LEN(A1))),LEN(A1))).

doc-extract-emails3

2. Then press Enter key, then select the cell B1, and drag the fill handle to the range that you want to contain this formula. And the email addresses in the range have been extracted from the text string. See screenshot:

doc-extract-emails4

Notes:

1. The punctuation after the email address also will be extracted.

2. If the cells don’t contain the email addresses, the formula will display error values.

3. If there are more than one email address in a cell, the formula will only extract the first address.


arrow blue right bubble Extract email address from text string with User Defined Function

Except the above formula, a User Defined Function also can help you get the email address from the text string.

1. Hold down the ALT + F11 keys, and it opens the Microsoft Visual Basic for Applications window.

2. Click Insert > Module, and paste the following macro in the Module window.

Function ExtractEmailFun(extractStr As String) As String
'Update 20130829
Dim CharList As String
On Error Resume Next
CheckStr = "[A-Za-z0-9._-]"
OutStr = ""
Index = 1
Do While True
    Index1 = VBA.InStr(Index, extractStr, "@")
    getStr = ""
    If Index1 > 0 Then
        For p = Index1 - 1 To 1 Step -1
            If Mid(extractStr, p, 1) Like CheckStr Then
                getStr = Mid(extractStr, p, 1) & getStr
            Else
                Exit For
            End If
        Next
        getStr = getStr & "@"
        For p = Index1 + 1 To Len(extractStr)
            If Mid(extractStr, p, 1) Like CheckStr Then
                getStr = getStr & Mid(extractStr, p, 1)
            Else
                Exit For
            End If
        Next
        Index = Index1 + 1
        If OutStr = "" Then
            OutStr = getStr
        Else
            OutStr = OutStr & Chr(10) & getStr
        End If
    Else
        Exit Do
    End If
Loop
ExtractEmailFun = OutStr
End Function

3. Then save the code and enter the formula =ExtractEmailFun(A1) in an adjacent blank cell, see screenshot:

doc-extract-emails5

4. And then press Enter key, select the cell B1, and drag the fill handle over to the range that you need the formula. And all email addresses have been extracted from the cell text. See screenshot:

doc-extract-emails6

Notes:

1. If the cells don’t have the email addresses, it will reveal blank cells.

2. If there are more than one email address in a cell, all the emails will be extracted.


arrow blue right bubble Extract email address from text string with VBA code

If you feel above formulas are troublesome for you, the following VBA code can help you extract the email addresses at one.

1. Hold down the ALT + F11 keys, and it opens a Microsoft Visual Basic for Applications window.

2. Click Insert > Module, and paste the following macro in the Module window.

VBA: extract email addresses from text string

Sub ExtractEmail()
'Update 20130829
Dim WorkRng As Range
Dim arr As Variant
Dim CharList As String
On Error Resume Next
xTitleId = "KutoolsforExcel"
Set WorkRng = Application.Selection
Set WorkRng = Application.InputBox("Range", xTitleId, WorkRng.Address, Type:=8)
arr = WorkRng.Value
CheckStr = "[A-Za-z0-9._-]"
For i = 1 To UBound(arr, 1)
    For j = 1 To UBound(arr, 2)
        extractStr = arr(i, j)
        outStr = ""
        Index = 1
        Do While True
            Index1 = VBA.InStr(Index, extractStr, "@")
            getStr = ""
            If Index1 > 0 Then
                For p = Index1 - 1 To 1 Step -1
                    If Mid(extractStr, p, 1) Like CheckStr Then
                        getStr = Mid(extractStr, p, 1) & getStr
                    Else
                        Exit For
                    End If
                Next
                getStr = getStr & "@"
                For p = Index1 + 1 To Len(extractStr)
                    If Mid(extractStr, p, 1) Like CheckStr Then
                        getStr = getStr & Mid(extractStr, p, 1)
                    Else
                        Exit For
                    End If
                Next
                Index = Index1 + 1
                If outStr = "" Then
                    outStr = getStr
                Else
                    outStr = outStr & Chr(10) & getStr
                End If
            Else
                Exit Do
            End If
        Loop
        arr(i, j) = outStr
    Next
Next
WorkRng.Value = arr
End Sub

3. Then Press F5 key to run this code, and you should select a range that you want to use the VBA in the popped out dialog, see screenshot:

doc-extract-emails7

4. Then click OK, and the email addresses have been extracted from the selected text strings. See screenshots:

doc-extract-emails8 -2 doc-extract-emails9

Notes:

1. If the cells haven’t the email addresses, it will reveal blank cells.

2. All the emails will be extracted, if there are more than one email addresses in a cell.

3. The extracted emails will cover the original data, so you'd better backup the data first if you need.


arrow blue right bubble Extract email address from text string with Kutools for Excel by one click

The above methods looks somewhat complicated for our Excel beginner, here, I can recommend you a quick and easy tool- Kutools for Excel, with its Extract Email Address utility, you can extract the email addresses from the text strings without much effort.

Kutools for Excel : with more than 300 handy Excel add-ins, free to try with no limitation in 60 days.

If you have installed Kutools for Excel, please do as follows:

1. Select the cells contain the text strings.

2. Click Kutools > Text > Extract Email Address, see screenshot:

doc-extract-emails10-10

3. And an Extract Email Address dialog box will pop out, select a cell where you want to put the result, see screenshot:

doc-extract-emails9

4. Then click OK button, all the email addresses have been extracted from the text strings, see screenshot:

doc-extract-emails9

Click to Download and free trial Kutools for Excel Now!


arrow blue right bubble Demo: Extract email address from text string with Kutools for Excel

Kutools for Excel: with more than 200 handy Excel add-ins, free to try with no limitation in 60 days. Download and free trial Now!


Related article:

How to extract domains from multiple email addresses in Excel?


Kutools for Excel Solves Most of Your Problems, and Increases Your Productivity by 80%

  • Reuse: Quickly insert complex formulas, charts and anything that you have used before; Encrypt Cells with password; Create Mailing List and send emails...
  • Super Formula Bar (easily edit multiple lines of text and formula); Reading Layout (easily read and edit large numbers of cells); Paste to Filtered Range...
  • Merge Cells/Rows/Columns without losing Data; Split Cells Content; Combine Duplicate Rows/Columns... Prevent Duplicate Cells; Compare Ranges...
  • Select Duplicate or Unique Rows; Select Blank Rows (all cells are empty); Super Find and Fuzzy Find in Many Workbooks; Random Select...
  • Exact Copy Multiple Cells without changing formula reference; Auto Create References to Multiple Sheets; Insert Bullets, Check Boxes and more...
  • Extract Text, Add Text, Remove by Position, Remove Space; Create and Print Paging Subtotals; Convert Between Cells Content and Comments...
  • Super Filter (save and apply filter schemes to other sheets); Advanced Sort by month/week/day, frequency and more; Special Filter by bold, italic...
  • Combine Workbooks and WorkSheets; Merge Tables based on key columns; Split Data into Multiple Sheets; Batch Convert xls, xlsx and PDF...
  • More than 300 powerful features. Supports Office/Excel 2007-2019 and 365. Supports all languages. Easy deploying in your enterprise or organization. Full features 30-day free trial.
kte tab 201905

Office Tab Brings Tabbed interface to Office, and Make Your Work Much Easier

  • Enable tabbed editing and reading in Word, Excel, PowerPoint, Publisher, Access, Visio and Project.
  • Open and create multiple documents in new tabs of the same window, rather than in new windows.
  • Increases your productivity by 50%, and reduces hundreds of mouse clicks for you every day!
officetab bottom
Say something here...
symbols left.
You are guest ( Sign Up? )
or post as a guest, but your post won't be published automatically.
Loading comment... The comment will be refreshed after 00:00.
  • To post as a guest, your comment is unpublished.
    Vivia Santos · 6 months ago
    Quando extraído mais que um email usando a macro, como separa-los depois usando uma outra célula ? Ou é possível extrair já separando ?
  • To post as a guest, your comment is unpublished.
    Jim Butler · 8 months ago
    Saved me hours of manual parsing. Thank you!
  • To post as a guest, your comment is unpublished.
    Ultraswift Network · 1 years ago
    Thank you!
  • To post as a guest, your comment is unpublished.
    Cedric · 1 years ago
    Hi. This is a great job! I am sure that hundreds of people learned new stuff because of it. But if you just want to extract email addresses, you can use extractemailaddress.com . It seemed simple and quick, and I hav pasted the result in my excel spreadsheet. great!
  • To post as a guest, your comment is unpublished.
    mohit som · 1 years ago
    12 xyz john_hayden@microsoft.com 34abcd

    abcd 1234 abcd xyz john_hayden@microsoft.com

    how to find the mail id in this string.....
  • To post as a guest, your comment is unpublished.
    Ricardo Barreto · 2 years ago
    Great Add ON! Congratulations! :)
  • To post as a guest, your comment is unpublished.
    Liviu · 2 years ago
    Hello, great job! Very useful.
  • To post as a guest, your comment is unpublished.
    Helen · 2 years ago
    I'm not sure if my comment went through, so I'm sending it again.

    Can I use the above VB script to extract domain names only? I don't need the email addresses.

    Thanks
    • To post as a guest, your comment is unpublished.
      Louie Clay · 2 years ago
      [quote name="Helen"]I'm not sure if my comment went through, so I'm sending it again.

      Can I use the above VB script to extract domain names only? I don't need the email addresses.

      Thanks[/quote]

      This works to extract the domain name only for the first email address in a cell (here arbitrarily cell A1)

      =MID(A1,FIND("@",A1)+1,FIND(" ",RIGHT(A1,LEN(A1)-FIND("@",A1)),1))
  • To post as a guest, your comment is unpublished.
    Helen · 2 years ago
    This VB script is awesome. Can it be modified to extract only the domain.names?
  • To post as a guest, your comment is unpublished.
    Helen · 2 years ago
    This formula is fabulous; however, I need to extract the domain names only, not the entire email address. I'm not a VB expert and couldn't find out a way to modify to extract out only the domain name. Can someone assist with this?

    Thanks
  • To post as a guest, your comment is unpublished.
    Sheryl Moss · 2 years ago
    I'm using Excel 2007on a HP. If you have Melanie Brown in A1 and wish for it to read Melanie.Brown@gmail.com in the same cell, how do you accomplish this? I have a string of manes to do the same way. Will some one help me with this?
  • To post as a guest, your comment is unpublished.
    Raul · 3 years ago
    Awsome info`s! Thanks
  • To post as a guest, your comment is unpublished.
    Manuel · 3 years ago
    Extremely helpful. Thanks a lot!!
  • To post as a guest, your comment is unpublished.
    Louie Clay · 3 years ago
    If I want to extract only one email address from A1, this formula does so and reports only a blank, not an error, if A1 contains no email address. I find this an easier solution than trying to master all these scripts, and it costs nothing.

    =IFERROR(TRIM(RIGHT(SUBSTITUTE(LEFT(A1,FIND(" ",A1&" ",FIND("@",A1))-1)," ",REPT(" ",LEN(A1))),LEN(A1))),"")
  • To post as a guest, your comment is unpublished.
    Navjot SINGH · 3 years ago
    Excellent, wonderfull. every one should must use..
  • To post as a guest, your comment is unpublished.
    Mark · 3 years ago
    since the formula has been a great help to me, I thought I'd share my experience. I run it against a list of html webscrapes which are sometimes so long that the formula errors out.

    According to wikipedia the maximum length of an email address is 254 characters so replacing the len(A1) portions with 256 improves the stability of the function:

    =TRIM(RIGHT(SUBSTITUTE(LEFT(A1,FIND (" ",A1&" ",FIND("@",A1))-1)," ", REPT(" ",256)),256))
  • To post as a guest, your comment is unpublished.
    anil · 3 years ago
    Dear Sir,
    How can i extract correct email ids from my email list example below

    a.hamilton@tradsingapore.com.sg
    aarabest@emirates.com.net.ae
    admin@countrywide.com.my
  • To post as a guest, your comment is unpublished.
    kelvin · 4 years ago
    i need more information how to extract emails
  • To post as a guest, your comment is unpublished.
    Manish · 4 years ago
    Brother, you are really genius.

    Below formula worked for me and saved manual intervention which used to take hours

    =TRIM(RIGHT(SUBSTITUTE(LEFT(H2,FIND (" ",H2&" ",FIND("@",H2))-1)," ", REPT(" ",LEN(H2))),LEN(H2)))


    God Bless you
  • To post as a guest, your comment is unpublished.
    Kiru · 4 years ago
    This is good! thank you.
  • To post as a guest, your comment is unpublished.
    The Chad · 4 years ago
    Thanks to the author of the original script; I went ahead and added a "; " separator in between multiple e-mail addresses.


    Function ExtractEmailFun(extractStr As String) As String
    'Update 20150723
    Dim CharList As String
    On Error Resume Next
    CheckStr = "[A-Za-z0-9._-]"
    ExtractEmailFun = ""
    Index = 1
    Do While True
    Index1 = VBA.InStr(Index, extractStr, "@")
    getStr = ""
    If Index1 > 0 Then
    For p = Index1 - 1 To 1 Step -1
    If Mid(extractStr, p, 1) Like CheckStr Then
    getStr = Mid(extractStr, p, 1) & getStr
    Else
    Exit For
    End If
    Next
    getStr = getStr & "@"
    For p = Index1 + 1 To Len(extractStr)
    If Mid(extractStr, p, 1) Like CheckStr Then
    getStr = getStr & Mid(extractStr, p, 1)
    Else
    getStr = getStr
    Exit For
    End If
    Next
    Index = Index1 + 1
    getStr = getStr & "; "
    If ExtractEmailFun = "" Then
    ExtractEmailFun = getStr
    Else
    ExtractEmailFun = ExtractEmailFun & Chr(10) & getStr
    End If
    Else
    Exit Do
    End If
    Loop
    End Function
  • To post as a guest, your comment is unpublished.
    The Chad · 4 years ago
    Hello all, I also was looking for a way to separate out the e-mail addresses, so I could put it into Outlook. I've added a "; " separator between the e-mail addresses so they don't run on together. Let me know what you think. Thanks to the author of the original for getting this together!


    Function ExtractEmailFun(extractStr As String) As String
    'Update 20150723
    Dim CharList As String
    On Error Resume Next
    CheckStr = "[A-Za-z0-9._-]"
    ExtractEmailFun = ""
    Index = 1
    Do While True
    Index1 = VBA.InStr(Index, extractStr, "@")
    getStr = ""
    If Index1 > 0 Then
    For p = Index1 - 1 To 1 Step -1
    If Mid(extractStr, p, 1) Like CheckStr Then
    getStr = Mid(extractStr, p, 1) & getStr
    Else
    Exit For
    End If
    Next
    getStr = getStr & "@"
    For p = Index1 + 1 To Len(extractStr)
    If Mid(extractStr, p, 1) Like CheckStr Then
    getStr = getStr & Mid(extractStr, p, 1)
    Else
    getStr = getStr
    Exit For
    End If
    Next
    Index = Index1 + 1
    getStr = getStr & "; "
    If ExtractEmailFun = "" Then
    ExtractEmailFun = getStr
    Else
    ExtractEmailFun = ExtractEmailFun & Chr(10) & getStr
    End If
    Else
    Exit Do
    End If
    Loop
    End Function
  • To post as a guest, your comment is unpublished.
    loni · 4 years ago
    This is great, but now I have a problem. There is a space instead of a period between all the email addresses (i.e. abcd@aol com), so the formula is not putting the end of all the email addresses (.net, .com, etc.) into the new column. How can I fix this?
  • To post as a guest, your comment is unpublished.
    Ulli · 5 years ago
    Thank you so much, this is very handy!
  • To post as a guest, your comment is unpublished.
    Nikita · 5 years ago
    Amazing! Big regards for VBS script! THX!
  • To post as a guest, your comment is unpublished.
    ME · 5 years ago
    no VBA just formula to be pasted into cell

    Just change the references ( the example below looks at Cell A1)

    =TRIM(RIGHT(SUBSTITUTE(LEFT(A1,FIND("@",A1)-1)," ",REPT(" ",99)),99))&MID(A1,FIND("@",A1),FIND(" ",A1&" ",FIND("@",A1))-FIND("@",A1))
    • To post as a guest, your comment is unpublished.
      Ahsan Hassan · 3 years ago
      [quote name="ME"]no VBA just formula to be pasted into cell

      Just change the references ( the example below looks at Cell A1)

      =TRIM(RIGHT(SUBSTITUTE(LEFT(A1,FIND("@",A1)-1)," ",REPT(" ",99)),99))&MID(A1,FIND("@",A1),FIND(" ",A1&" ",FIND("@",A1))-FIND("@",A1))[/quote]


      Thank you. It worked for me.
    • To post as a guest, your comment is unpublished.
      Denis de Castro BMCP · 5 years ago
      [quote name="ME"]...

      =TRIM(RIGHT(SUBSTITUTE(LEFT(A1,FIND("@",A1)-1)," ",REPT(" ",99)),99))&MID(A1,FIND("@",A1),FIND(" ",A1&" ",FIND("@",A1))-FIND("@",A1))[/quote]

      Thanks "ME", works verbatim in Google spreadsheet!
  • To post as a guest, your comment is unpublished.
    Neal · 5 years ago
    Great code! Really useful. Unfortunately it's concatenating multiple email addresses rather than separating them usefully, for example with a semicolon. How would you add in a separator?
  • To post as a guest, your comment is unpublished.
    Justin · 5 years ago
    Thanks for this formula! You just saved me a ton of work - had to extract 1500 emails from a poorly written Excel sheet for an email marketing list. Once I finally found your formula it was a snap.
  • To post as a guest, your comment is unpublished.
    penn · 5 years ago
    very helpful, thanks!
  • To post as a guest, your comment is unpublished.
    manas · 5 years ago
    LUL USE THIS CODE FOR EMAIL EXTRACT.

    Sub lula()
    Dim d1 As Variant
    cntr = 0
    rowstring = ActiveCell.Offset(0, 0).Value

    d1 = Split(rowstring, " ")


    Do

    'MsgBox d1(cntr)
    cntr = cntr + 1
    If d1(cntr) = "" Then GoTo ttt
    If InStr(d1(cntr), "@") Then
    MsgBox d1(cntr)
    GoTo ttt
    End If

    Loop While d1(cntr) ""


    ttt:
    End Sub