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?


Excel Productivity Tools

Ribbon of Excel (with Kutools for Excel installed)

300+ Advanced Features Increase Your Productivity by 70%, and Help You To Stand Out From Crowd!

Would you like to complete your daily work quickly and perfectly? Kutools For Excel brings 300+ cool and powerful advanced features (Combine workbooks, sum by color, split cell contents, convert date, and so on...) for 1500+ work scenarios, helps you solve 80% Excel problems.

  • Deal with all complicated tasks in seconds, help to enhance your work ability, get success from the fierce competition, and never worry about being fired.
  • Save a lot of work time, leave much time for you to love and care the family and enjoy a comfortable life now.
  • Reduce thousands of keyboard and mouse clicks every day, relieve your tired eyes and hands, and give you a healthy body.
  • Become an Excel expert in 3 minutes, and get admiring glance from your colleagues or friends.
  • No longer need to remember any painful formulas and VBA codes, have a relaxing and pleasant mind, give you a thrill you've never had before.
  • Spend only $39, but worth than $4000 training of others. Being used by 110,000 elites and 300+ well-known companies.
  • 60-day unlimited free trial. 60-day money back guarantee. Free upgrade and support for 2 years. Buy once, use forever.
  • Change the way you work now, and give you a better life immediately!

Office Tab Brings Efficient And Handy Tabs to Office (include Excel), Just Like Chrome, Firefox, And New IE

  • Increases your productivity by 50% when viewing and editing multiple documents.
  • Reduce hundreds of mouse clicks for you every day, say goodbye to mouse hand.
  • Open and create documents in new tabs of same window, rather than in new windows.
  • Help you work faster and easily stand out from the crowd! One second to switch between dozens of open documents!
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.
    Jim Butler · 1 months ago
    Saved me hours of manual parsing. Thank you!
  • To post as a guest, your comment is unpublished.
    Ultraswift Network · 7 months ago
    Thank you!
  • To post as a guest, your comment is unpublished.
    Cedric · 7 months 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 · 1 years ago
    Great Add ON! Congratulations! :)