Note: The other languages of the website are Google-translated. Back to English
Log på  \/ 
x
or
x
Tilmeld  \/ 
x

or

Hvordan udpakkes hurtigt e-mail-adresse fra tekststreng?

Når du importerer nogle e-mail-adresser fra webstedet til Excel-regneark, indeholder der altid irrelevant tekst, men nu vil du bare udtrække de rene e-mail-adresser fra tekststrengen (se følgende skærmbilleder). Hvordan kunne du hurtigt kun få e-mail-adresserne fra celleteksten?

doc-uddrag-emails1 -2 doc-uddrag-emails2

Uddrag e-mail-adresse fra tekststreng med formel

Uddrag e-mail-adresse fra tekststreng med brugerdefineret funktion

Uddrag e-mail-adresse fra tekststreng med VBA-kode

Uddrag e-mail-adresse fra tekststreng med Kutools til Excel


pil blå højre boble Uddrag e-mail-adresse fra tekststreng med formel

Her introducerer jeg dig en lang formel for kun at udtrække e-mail-adresserne fra teksten i Excel. Gør som følger:

1. Indtast denne formel i den tilstødende celle B1 = TRIM (HØJRE (SUBSTITUT (VENSTRE (A1, FIND ("", A1 & "", FIND ("@", A1)) - 1), "", REPT ("", LEN (A1))), LEN ( A1))).

doc-uddrag-emails3

2. Tryk derefter på Indtast nøgle, vælg derefter celle B1, og træk fyldhåndtaget til det område, du vil indeholde denne formel. Og e-mail-adresserne i området er udvundet fra tekststrengen. Se skærmbillede:

doc-uddrag-emails4

Bemærkninger:

1. Tegnsætningen efter e-mail-adressen ekstraheres også.

2. Hvis cellerne ikke indeholder e-mail-adresserne, viser formlen fejlværdier.

3. Hvis der er mere end en e-mail-adresse i en celle, udtrækker formlen kun den første adresse.


Uddrag flere e-mail-adresser fra tekststrenge

Kutools til Excel's Uddrag e-mail-adresse kan hjælpe dig med at udtrække e-mail-adresserne fra tekststrengene hurtigt og bekvemt. Klik for at downloade Kutools til Excel!

doc uddrag e-mails-1

Kutools til Excel: med mere end 300 praktiske Excel-tilføjelsesprogrammer, gratis at prøve uden begrænsning på 30 dage. Download og gratis prøveversion nu!


pil blå højre boble Uddrag e-mail-adresse fra tekststreng med brugerdefineret funktion

Bortset fra ovenstående formel kan en brugerdefineret funktion også hjælpe dig med at få e-mail-adressen fra tekststrengen.

1. Hold nede ALT + F11 tasterne, og det åbner Microsoft Visual Basic til applikationer vindue.

2. Klik indsatte > Moduler, og indsæt følgende makro i modulvinduet.

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. Gem derefter koden, og indtast formlen = ExtractEmailFun (A1) i en tilstødende tom celle, se skærmbillede:

doc-uddrag-emails5

4. Og tryk derefter på Indtast nøgle, vælg celle B1, og træk udfyldningshåndtaget over til det område, som du har brug for formlen. Og alle e-mail-adresser er udvundet fra celleteksten. Se skærmbillede:

doc-uddrag-emails6

Bemærkninger:

1. Hvis cellerne ikke har e-mail-adresserne, afslører det tomme celler.

2. Hvis der er mere end en e-mail-adresse i en celle, udpakkes alle e-mails.


pil blå højre boble Uddrag e-mail-adresse fra tekststreng med VBA-kode

Hvis du føler, at ovenstående formler er besværlige for dig, kan følgende VBA-kode hjælpe dig med at udtrække e-mail-adresserne ad gangen.

1. Hold nede ALT + F11 taster, og det åbner en Microsoft Visual Basic til applikationer vindue.

2. Klik indsatte > Moduler, og indsæt følgende makro i Modulvindue.

VBA: udpak e-mail-adresser fra tekststreng

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. Tryk derefter på F5 nøgle til at køre denne kode, og du skal vælge et område, som du vil bruge VBA i den poppede dialog, se skærmbillede:

doc-uddrag-emails7

4. Klik derefter på OK, og e-mail-adresserne er udvundet fra de valgte tekststrenge. Se skærmbilleder:

doc-uddrag-emails8 -2 doc-uddrag-emails9

Bemærkninger:

1. Hvis cellerne ikke har e-mail-adresserne, afslører det tomme celler.

2. Alle e-mails ekstraheres, hvis der er mere end en e-mail-adresse i en celle.

3. De udpakkede e-mails dækker de originale data, så du må hellere sikkerhedskopiere dataene, hvis du har brug for det.


pil blå højre boble Uddrag e-mail-adresse fra tekststreng med Kutools til Excel med et enkelt klik

Ovenstående metoder ser noget kompliceret ud for vores Excel-nybegynder, her kan jeg anbefale dig et hurtigt og nemt værktøj- Kutools til Excel, Med Uddrag e-mail-adresse værktøj, kan du udtrække e-mail-adresserne fra tekststrengene uden megen anstrengelse.

Kutools til Excel : med mere end 300 praktiske Excel-tilføjelsesprogrammer, gratis at prøve uden begrænsning på 30 dage.

Hvis du har installeret Kutools til Excelskal du gøre som følger:

1. Vælg cellerne, der indeholder tekststrengene.

2. Klik Kutools > tekst > Uddrag e-mail-adresse, se skærmbillede:

3. Og en Uddrag e-mail-adresse dialogboksen vises, vælg en celle, hvor du vil placere resultatet, se skærmbillede:

doc-uddrag-emails9

4. Klik derefter på OK knap, alle e-mail-adresserne er udvundet fra tekststrengene, se skærmbillede:

doc-uddrag-emails9

Klik for at downloade og gratis prøveversion Kutools til Excel nu!


pil blå højre boble Demo: Uddrag e-mail-adresse fra tekststreng med Kutools til Excel

Kutools til Excel: med mere end 300 praktiske Excel-tilføjelsesprogrammer, gratis at prøve uden begrænsning på 30 dage. Download og gratis prøveversion nu!

Relateret artikel:

Hvordan udpakkes domæner fra flere e-mail-adresser i Excel?


De bedste Office-produktivitetsværktøjer

Kutools til Excel løser de fleste af dine problemer og øger din produktivitet med 80%

  • Genbruge: Indsæt hurtigt komplekse formler, diagrammer og alt, hvad du har brugt før; Krypter celler med adgangskode Opret postliste og send e-mails ...
  • Super formel bar (let redigere flere linjer med tekst og formel); Læsning Layout (let at læse og redigere et stort antal celler); Indsæt til filtreret rækkevidde...
  • Flet celler / rækker / kolonner uden at miste data; Split celler indhold; Kombiner duplikerede rækker / kolonner... Forhindre duplikerede celler; Sammenlign områder...
  • Vælg Duplicate eller Unique Rækker; Vælg tomme rækker (alle celler er tomme); Super Find og Fuzzy Find i mange arbejdsbøger; Tilfældig valg ...
  • Præcis kopi Flere celler uden at ændre formelreference; Auto Opret referencer til flere ark; Indsæt kugler, Afkrydsningsfelter og mere ...
  • Uddrag tekst, Tilføj tekst, Fjern efter position, Fjern mellemrum; Opret og udskriv personsøgningssubtotaler; Konverter mellem celler indhold og kommentarer...
  • Superfilter (gem og anvend filterskemaer på andre ark); Avanceret sortering efter måned / uge / dag, hyppighed og mere; Specielt filter af fed, kursiv ...
  • Kombiner arbejdsbøger og arbejdsark; Fletabeller baseret på nøglekolonner; Opdel data i flere ark; Batch Konverter xls, xlsx og PDF...
  • Mere end 300 kraftfulde funktioner. Understøtter Office / Excel 2007-2019 og 365. Understøtter alle sprog. Nem implementering i din virksomhed eller organisation. Fuld funktioner 30-dages gratis prøveperiode. 60-dages pengene tilbage garanti.
kte-fane 201905

Fanen Office bringer en grænseflade til et kontor med Office, og gør dit arbejde meget lettere

  • Aktiver redigering og læsning af faner i Word, Excel, PowerPoint, Publisher, Access, Visio og Project.
  • Åbn og opret flere dokumenter i nye faner i det samme vindue snarere end i nye vinduer.
  • Øger din produktivitet med 50%og reducerer hundredvis af museklik for dig hver dag!
officetab bund
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 · 5 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