ExcelReady
CourseMock testsFunction guidesBlog
Start freeStart learning for free
ExcelReady

Be Excel-ready before day one. Hands-on practice in your browser, with instant feedback.

Learn

  • Course
  • Mock tests
  • Function guides
  • Blog

Test prep

  • Excel level test
  • Excel test practice
  • Free screening quiz
  • Certificate

Company

  • Editorial policy
  • Contact
  • Terms
  • Privacy

© 2026 ExcelReady. All rights reserved.

  1. Blog
  2. Text
  3. Extract the Domain or Username From an Email in Excel

Extract the Domain or Username From an Email in Excel

By ExcelReady Team·Updated November 1, 2026·7 min read

The short answer

To extract the domain from an email address, take everything after the @ sign. In Microsoft 365, use =TEXTAFTER(A2,"@"). In any version, use =MID(A2,FIND("@",A2)+1,LEN(A2)). For the username, take everything before the @: =TEXTBEFORE(A2,"@") or =LEFT(A2,FIND("@",A2)-1). Wrap either in IFERROR for cells without an @.

Key takeaways

  • Every email has one @ sign, so FIND("@",A2) gives the split point.
  • Domain: =TEXTAFTER(A2,"@") in Microsoft 365, or =MID(A2,FIND("@",A2)+1,LEN(A2)) in any version.
  • Username: =TEXTBEFORE(A2,"@"), or =LEFT(A2,FIND("@",A2)-1).
  • Use LOWER and TRIM first so the same domain isn't counted twice.
  • Cells without an @ return an error; wrap the formula in IFERROR.
On this page+
  1. How email addresses split
  2. Extract the domain with TEXTAFTER
  3. Extract the domain with MID and FIND
  4. Extract the username
  5. Get the company name from the domain
  6. Extract the top-level domain
  7. Extract domains without a formula
  8. Clean the addresses first
  9. Count emails by domain
  10. Fix errors for cells without an @
  11. Practise it

To extract the domain from an email address in Excel, you take everything after the @ sign; for the username, you take everything before it. In Microsoft 365, TEXTAFTER and TEXTBEFORE do this with one short formula each. In any version, MID, LEFT and FIND do the same job. This guide shows both ways, plus how to get the company name, count by domain, and handle messy addresses.

All the examples use this list of email addresses:

A
1Email
2maria.lopez@contoso.com
3j.chen@fabrikam.com
4sam.okoro@example.org
5lena@tailspintoys.com

How email addresses split#

Every email address has exactly one @ sign. The part before it is the username, and the part after it is the domain. So all you need is the position of the @, and FIND gives you that:

Excel formula
=FIND("@",A2)

For "maria.lopez@contoso.com", the result is 12: "maria.lopez" is 11 characters, so the @ is the 12th. Everything else builds on this number.

Extract the domain with TEXTAFTER#

TEXTAFTER returns the text after a delimiter, which is a character that marks where to split:

Excel formula
=TEXTAFTER(A2,"@")

The result is contoso.com. Fill it down and you get fabrikam.com, example.org and tailspintoys.com. TEXTAFTER needs Microsoft 365, Excel 2024 or Excel for the web. The TEXTBEFORE and TEXTAFTER lesson has more examples.

Extract the domain with MID and FIND#

In older versions of Excel, use MID to take the text starting just after the @:

Excel formula
=MID(A2,FIND("@",A2)+1,LEN(A2))

Here is how it works for maria.lopez@contoso.com:

PartResult
FIND("@",A2)12
FIND("@",A2)+113, the first character of the domain
LEN(A2)23, the length of the whole address
MID(A2,13,23)contoso.com

LEN(A2) asks for more characters than are left, and that's fine: MID just stops at the end of the text. It's a simple way to say "take the rest". You could also use =RIGHT(A2,LEN(A2)-FIND("@",A2)), which takes 23 - 12 = 11 characters from the right. The MID function guide and FIND function guide explain each part, and the MID function article has more worked examples.

Extract the username#

The username is everything before the @. In Microsoft 365:

Excel formula
=TEXTBEFORE(A2,"@")

In any version, take the characters from the left up to one before the @:

Excel formula
=LEFT(A2,FIND("@",A2)-1)

Both return maria.lopez. The -1 stops LEFT just before the @, so the @ isn't included. For the pros and cons of each approach, see LEFT vs TEXTBEFORE.

Many usernames follow a first.last pattern. To split "maria.lopez" into a first and last name, use the same trick with the dot: =TEXTBEFORE(TEXTBEFORE(A2,"@"),".") returns maria. The guide to splitting a full name shows the same method on names with spaces.

Get the company name from the domain#

Sometimes you want "contoso" rather than "contoso.com". That's the text between the @ and the first dot after it:

Excel formula
=TEXTBEFORE(TEXTAFTER(A2,"@"),".")

The result is contoso. For a domain like "mail.contoso.co.uk", this returns "mail", so check your data for subdomains first. Extracting text between two different characters is covered step by step in how to extract text between characters.

Extract the top-level domain#

The top-level domain is the last part of the address, such as com, org or uk. TEXTAFTER can count delimiters from the end when you give it a negative instance number:

Excel formula
=TEXTAFTER(A2,".",-1)

This returns the text after the last dot: com for maria.lopez@contoso.com and org for sam.okoro@example.org. The -1 means "the first dot counting from the right". It's a quick way to group contacts by country domains like .de or .fr.

Extract domains without a formula#

Two menu tools can split emails without any formula:

  • Flash Fill. In B2, type the domain of the first email by hand, such as contoso.com. Start typing the second, and Excel suggests the rest. Press Enter to accept, or use Data > Flash Fill (Windows: Ctrl+E).
  • Text to Columns. Select the emails, choose Data > Text to Columns, pick Delimited, and type @ in the Other box. Excel puts usernames in one column and domains in the next.

Both are fast for a one-off list, but the results don't update when the emails change. Formulas do, so use them when the list keeps growing.

Clean the addresses first#

Email lists collected from forms are rarely tidy. Before extracting, clean the column so the same domain doesn't appear in different forms:

Excel formula
=LOWER(TRIM(A2))

TRIM removes stray spaces, and LOWER turns "Contoso.com" and "CONTOSO.COM" into the same text. Email addresses aren't case-sensitive in practice, so lower case is the safe standard. Then run your domain formula on the cleaned column.

Count emails by domain#

Once you have a Domain column, a COUNTIF or a PivotTable tells you how many contacts come from each company. You can also skip the helper column and count straight from the addresses with a wildcard:

Excel formula
=COUNTIF(A2:A5,"*@contoso.com")

The * stands for any username, so this counts every address ending in @contoso.com: 1 in the example list. In Microsoft 365, =UNIQUE(TEXTAFTER(A2:A5,"@")) lists each domain once.

Fix errors for cells without an @#

If a cell has no @, because it's empty or holds a typo, FIND returns #VALUE! and TEXTAFTER returns #N/A. Wrap the formula in IFERROR to show a blank or a message:

Excel formula
=IFERROR(MID(A2,FIND("@",A2)+1,LEN(A2)),"Check email")

Rows that say "Check email" are the ones to fix by hand. To check that each cell has exactly one @, count them with LEN and SUBSTITUTE: =LEN(A2)-LEN(SUBSTITUTE(A2,"@","")) returns 1 for a valid address. The guide to counting characters and words explains this trick.

Practise it#

Splitting text at a character is one of the most useful text skills for data work. Practise TEXTBEFORE and TEXTAFTER in a live spreadsheet: you type the formula and it checks the result instantly. Then practise LEFT, RIGHT, MID and LEN so you can do the same in any version of Excel.

Try it yourself

This is a live spreadsheet. Type the formula in the green cell and press Enter.

Pull the domain out of the email in A2. In B2, use MID and FIND to take everything after the @ sign. Use LEN(A2) as the number of characters.

fx
ABCD
1
Email
Domain
2
maria.lopez@contoso.com
3
j.chen@fabrikam.com
4
sam.okoro@example.org
5
lena@tailspintoys.com
6
7
8

Tip: Start at FIND("@",A2)+1, one character after the @. LEN(A2) is long enough to take the rest.

Practise this in a lesson

LessonTEXTBEFORE and TEXTAFTERSplit emails, "Last, First" names and file paths at a delimiter with TEXTBEFORE and TEXTAFTER, including picking which occurrence to split at.LessonLEFT, RIGHT, MID and LENSplit product codes and IDs into their parts by taking characters from the start, end or middle of the text.Function guideFINDLocate a character inside text with Excel's FIND, then use it with LEFT, MID and RIGHT. Case rules, #VALUE! fixes and a live exercise.Function guideMIDPull characters from any position with Excel's MID. Extract IDs, email domains and text between brackets with FIND. Examples and live practice.

Frequently asked questions

How do I extract the domain from an email address in Excel?

+

Use =TEXTAFTER(A2,"@") in Microsoft 365 or Excel 2024. In older versions, use =MID(A2,FIND("@",A2)+1,LEN(A2)). Both return everything after the @ sign.

How do I get the username from an email in Excel?

+

Use =TEXTBEFORE(A2,"@"), or =LEFT(A2,FIND("@",A2)-1) in any version. Both return everything before the @ sign.

How do I get just the company name from an email domain?

+

Take the text between the @ and the first dot: =TEXTBEFORE(TEXTAFTER(A2,"@"),"."). For maria@contoso.com, this returns contoso.

How do I count emails by domain?

+

Use COUNTIF with a wildcard: =COUNTIF(A2:A100,"*@contoso.com") counts the addresses that end in @contoso.com.

Can Flash Fill extract email domains?

+

Yes. Type the first domain by hand next to the email, start the second one, and press Enter to accept the preview, or press Ctrl+E on Windows. It won't update if the emails change, though.

Sources

  • TEXTAFTER function - Microsoft Support
  • MID, MIDB functions - Microsoft Support
  • FIND, FINDB functions - Microsoft Support

Written and checked by the ExcelReady Team. First published November 1, 2026. The practice exercise runs in the same formula engine as our lessons. Found a mistake? Read our editorial policy or email hello@excelready.app.

On this page

  1. How email addresses split
  2. Extract the domain with TEXTAFTER
  3. Extract the domain with MID and FIND
  4. Extract the username
  5. Get the company name from the domain
  6. Extract the top-level domain
  7. Extract domains without a formula
  8. Clean the addresses first
  9. Count emails by domain
  10. Fix errors for cells without an @
  11. Practise it

Keep reading

Text· 6 min read

Extract Text Between Two Characters in Excel

To extract text between two characters in Microsoft 365, nest TEXTAFTER inside TEXTBEFORE: =TEXTBEFORE(TEXTAFTER(A2,"("),")") returns what sits between the brackets. In any version, use MID and FIND: =MID(A2,FIND("(",A2)+1,FIND(")",A2)-FIND("(",A2)-1). FIND gives the positions of the two characters, and MID takes the text between them.

Text· 7 min read

How to Split First and Last Names in Excel

To split a full name in Excel, use =TEXTBEFORE(A2," ") for the first name and =TEXTAFTER(A2," ",-1) for the last name, which also handles middle names. In Excel 2021 and older, use =LEFT(A2,FIND(" ",A2)-1) for the first name. For a one-off job, Data > Text to Columns or Flash Fill splits names without formulas.

Text· 7 min read

MID Function in Excel: Pull Text From the Middle

The MID function in Excel returns a set number of characters from the middle of text. Write =MID(text, start_num, num_chars): the text, the position to start at, and how many characters to take. For example, =MID("ORD-2024-0081",5,4) returns 2024. For text of varying length, use FIND or SEARCH to work out the start position.

Don't just read about Excel. Do it.

Practise real formulas in a live spreadsheet with instant feedback, right in your browser. Nothing to download.

Start learning for free