Note: The other languages of the website are Google-translated. Back to English
Masuk  \/ 
x
or
x
Daftar  \/ 
x

or

Bagaimana cara cepat mengekstrak alamat email dari string teks?

Saat Anda mengimpor beberapa alamat email dari lembar kerja Situs web ke Excel, selalu ada teks yang tidak relevan, tetapi sekarang Anda hanya ingin mengekstrak alamat email murni dari string teks (lihat tangkapan layar berikut). Bagaimana Anda bisa dengan cepat hanya mendapatkan alamat email dari teks seluler?

doc-extract-email1 -2 doc-extract-email2

Ekstrak alamat email dari string teks dengan Formula

Ekstrak alamat email dari string teks dengan User Defined Function

Ekstrak alamat email dari string teks dengan kode VBA

Ekstrak alamat email dari string teks dengan Kutools for Excel


panah gelembung kanan biru Ekstrak alamat email dari string teks dengan Formula

Di sini saya perkenalkan Anda rumus panjang untuk mengekstrak hanya alamat email dari teks di Excel. Harap lakukan sebagai berikut:

1. Di sel B1 yang berdekatan, masukkan rumus ini = PANGKAS (KANAN (PENGGANTI (KIRI (A1, TEMUKAN ("", A1 & "", TEMUKAN ("@", A1)) - 1), "", REPT ("", LEN (A1))), LEN ( A1))).

doc-extract-email3

2. Lalu tekan Memasukkan kunci, lalu pilih sel B1, dan seret gagang isian ke rentang yang Anda inginkan untuk memuat rumus ini. Dan alamat email dalam rentang tersebut telah diekstrak dari string teks. Lihat tangkapan layar:

doc-extract-email4

Catatan:

1. Tanda baca setelah alamat email juga akan diambil.

2. Jika sel tidak berisi alamat email, rumus akan menampilkan nilai kesalahan.

3. Jika ada lebih dari satu alamat email dalam satu sel, rumus hanya akan mengekstrak alamat pertama.


Ekstrak Beberapa Alamat Email dari string teks

Kutools untuk Excel'S Ekstrak Alamat Email dapat membantu Anda mengekstrak alamat email dari string teks dengan cepat dan nyaman. Klik untuk mengunduh Kutools for Excel!

doc ekstrak email-1

Kutools untuk Excel: dengan lebih dari 300 add-in Excel yang praktis, gratis untuk dicoba tanpa batasan dalam 30 hari. Unduh dan uji coba gratis Sekarang!


panah gelembung kanan biru Ekstrak alamat email dari string teks dengan User Defined Function

Selain rumus di atas, User Defined Function juga dapat membantu Anda mendapatkan alamat email dari string teks.

1. Tahan ALT + F11 kunci, dan itu membuka Microsoft Visual Basic untuk Aplikasi jendela.

2. Klik Menyisipkan > Modul, dan tempelkan makro berikut di jendela modul.

Function ExtractEmailFun(extractStr As String) As String
'Update by extendoffice
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. Kemudian simpan kodenya dan masukkan rumusnya = ExtractEmailFun (A1) di sel kosong yang berdekatan, lihat tangkapan layar:

doc-extract-email5

4. Lalu tekan Memasukkan kunci, pilih sel B1, dan seret gagang isian ke kisaran yang Anda perlukan rumusnya. Dan semua alamat email telah diekstrak dari teks sel. Lihat tangkapan layar:

doc-extract-email6

Catatan:

1. Jika sel tidak memiliki alamat email, ini akan mengungkapkan sel kosong.

2. Jika ada lebih dari satu alamat email dalam satu sel, semua email akan diekstrak.


panah gelembung kanan biru Ekstrak alamat email dari string teks dengan kode VBA

Jika Anda merasa rumus di atas merepotkan Anda, kode VBA berikut ini bisa membantu Anda mengekstrak alamat email sekaligus.

1. Tahan ALT + F11 kunci, dan itu membuka a Microsoft Visual Basic untuk Aplikasi jendela.

2. Klik Menyisipkan > Modul, dan tempelkan makro berikut di file Jendela modul.

VBA: ekstrak alamat email dari string teks

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. Lalu tekan F5 kunci untuk menjalankan kode ini, dan Anda harus memilih rentang yang ingin Anda gunakan VBA di dialog yang muncul, lihat tangkapan layar:

doc-extract-email7

4. Lalu klik OK, dan alamat email telah diekstrak dari string teks yang dipilih. Lihat tangkapan layar:

doc-extract-email8 -2 doc-extract-email9

Catatan:

1. Jika sel tidak memiliki alamat email, itu akan mengungkapkan sel kosong.

2. Semua email akan diekstrak, jika ada lebih dari satu alamat email dalam satu sel.

3. Email yang diekstrak akan menutupi data asli, jadi sebaiknya backup data terlebih dahulu jika perlu.


panah gelembung kanan biru Ekstrak alamat email dari string teks dengan Kutools for Excel dengan satu klik

Metode di atas terlihat agak rumit untuk pemula Excel kami, di sini, saya dapat merekomendasikan Anda alat yang cepat dan mudah- Kutools untuk Excel, Dengan yang Ekstrak Alamat Email utilitas, Anda dapat mengekstrak alamat email dari string teks tanpa banyak usaha.

Kutools untuk Excel : dengan lebih dari 300 add-in Excel yang praktis, gratis untuk dicoba tanpa batasan dalam 30 hari.

Jika sudah terpasang Kutools untuk Excel, lakukan hal berikut:

1. Pilih sel yang berisi string teks.

2. Klik Kutools > Teks > Ekstrak Alamat Email, lihat tangkapan layar:

3. Dan a Ekstrak Alamat Email kotak dialog akan muncul, pilih sel tempat Anda ingin meletakkan hasilnya, lihat tangkapan layar:

doc-extract-email9

4. Lalu klik OK tombol, semua alamat email telah diekstrak dari string teks, lihat tangkapan layar:

doc-extract-email9

Klik untuk Mengunduh dan uji coba gratis Kutools for Excel Sekarang!


panah gelembung kanan biru Demo: Ekstrak alamat email dari string teks dengan Kutools for Excel

Kutools untuk Excel: dengan lebih dari 300 add-in Excel yang praktis, gratis untuk dicoba tanpa batasan dalam 30 hari. Unduh dan uji coba gratis Sekarang!

Artikel terkait:

Bagaimana cara mengekstrak domain dari beberapa alamat email di Excel?


Alat Produktivitas Kantor Terbaik

Kutools for Excel Memecahkan Sebagian Besar Masalah Anda, dan Meningkatkan Produktivitas Anda hingga 80%

  • Reuse: Masukkan dengan cepat rumus, bagan yang kompleks dan apa pun yang pernah Anda gunakan sebelumnya; Enkripsi Sel dengan kata sandi; Buat Milis dan mengirim email ...
  • Super Formula Bar (dengan mudah mengedit beberapa baris teks dan rumus); Membaca Tata Letak (membaca dan mengedit sel dalam jumlah besar dengan mudah); Tempel ke Rentang yang Difilter...
  • Gabungkan Sel / Baris / Kolom tanpa kehilangan Data; Pisahkan Konten Sel; Gabungkan Baris / Kolom Duplikat... Mencegah Sel Duplikat; Bandingkan Rentang...
  • Pilih Duplikat atau Unik Baris; Pilih Baris Kosong (semua sel kosong); Temukan Super dan Temukan Fuzzy di Banyak Buku Kerja; Pilih Acak ...
  • Salinan Tepat Beberapa Sel tanpa mengubah referensi rumus; Buat Referensi Otomatis ke Beberapa Lembar; Sisipkan Poin, Kotak Centang, dan lainnya ...
  • Ekstrak Teks, Tambahkan Teks, Hapus berdasarkan Posisi, Hapus Space; Membuat dan Mencetak Subtotal Paging; Konversi Konten Antar Sel dan Komentar...
  • Filter Super (simpan dan terapkan skema filter ke sheet lain); Penyortiran Lanjutan menurut bulan / minggu / hari, frekuensi dan lainnya; Filter Khusus dengan huruf tebal, miring ...
  • Gabungkan Workbooks dan WorkSheets; Gabungkan Tabel berdasarkan kolom kunci; Pisahkan Data menjadi Beberapa Lembar; Konversi Batch xls, xlsx dan PDF...
  • Lebih dari 300 fitur canggih. Mendukung Office / Excel 2007-2019 dan 365. Mendukung semua bahasa. Penerapan yang mudah di perusahaan atau organisasi Anda. Fitur lengkap uji coba gratis 30 hari. Jaminan uang kembali 60 hari.
tab kte 201905

Tab Office Membawa antarmuka Tab ke Office, dan Membuat Pekerjaan Anda Jauh Lebih Mudah

  • Aktifkan pengeditan dan pembacaan tab di Word, Excel, PowerPoint, Publisher, Access, Visio, dan Project.
  • Buka dan buat banyak dokumen di tab baru di jendela yang sama, bukan di jendela baru.
  • Meningkatkan produktivitas Anda sebesar 50%, dan mengurangi ratusan klik mouse untuk Anda setiap hari!
officetab bawah
Say something here...
symbols left.
You are guest
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.
    Skeleton · 5 months ago
    Really helpful to extract emails in a neat way, thank you!
  • To post as a guest, your comment is unpublished.
    avat · 6 months ago
    Malheureusement la première formule donnée se met en erreur....
  • To post as a guest, your comment is unpublished.
    Jack · 1 years ago
    Thank you very much, spend only half hour looking for this and save me ten hours of work!


  • To post as a guest, your comment is unpublished.
    Daniel · 1 years ago
    This is the most useful page I have ever found on Excel - thank you.
  • To post as a guest, your comment is unpublished.
    Donna · 1 years ago
    How do you extract multiple email addresses for one cell?
    • To post as a guest, your comment is unpublished.
      skyyang · 1 years ago
      Hi, Donna,
      The second and the third methods in this article can help you to extract multiple Email addresses from one cell, please try, thank you!
  • To post as a guest, your comment is unpublished.
    vivia.santos.ctrl@gmail.com · 2 years 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 · 2 years ago
    Saved me hours of manual parsing. Thank you!
  • To post as a guest, your comment is unpublished.
    ultraswiftventures@gmail.com · 3 years ago
    Thank you!
  • To post as a guest, your comment is unpublished.
    Pa · 3 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.
    mohit10som@gmail.com · 3 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 · 4 years ago
    Great Add ON! Congratulations! :)
  • To post as a guest, your comment is unpublished.
    Liviu · 4 years ago
    Hello, great job! Very useful.
  • To post as a guest, your comment is unpublished.
    Helen · 4 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 · 4 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 · 4 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 · 4 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 · 4 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 · 5 years ago
    Awsome info`s! Thanks
  • To post as a guest, your comment is unpublished.
    Manuel · 5 years ago
    Extremely helpful. Thanks a lot!!
  • To post as a guest, your comment is unpublished.
    Louie Clay · 5 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 · 5 years ago
    Excellent, wonderfull. every one should must use..
  • To post as a guest, your comment is unpublished.
    Mark · 5 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 · 5 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 · 6 years ago
    i need more information how to extract emails
  • To post as a guest, your comment is unpublished.
    Manish · 6 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 · 6 years ago
    This is good! thank you.
  • To post as a guest, your comment is unpublished.
    The Chad · 6 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 · 6 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 · 6 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 · 7 years ago
    Thank you so much, this is very handy!
  • To post as a guest, your comment is unpublished.
    Nikita · 7 years ago
    Amazing! Big regards for VBS script! THX!
  • To post as a guest, your comment is unpublished.
    ME · 7 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 · 5 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 · 7 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 · 7 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 · 7 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 · 7 years ago
    very helpful, thanks!
  • To post as a guest, your comment is unpublished.
    manas · 7 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