Excel guide · 3 min read
How to extract the domain from an email address in Excel
=TEXTAFTER(A2,"@"). In any version, use =MID(A2,FIND("@",A2)+1,LEN(A2)), which returns everything after the @ sign. Wrap either one in LOWER(TRIM(...)) so "Contoso.com" and " contoso.com" count as the same domain.Sample data
Every result on this page was calculated from this sheet by the same spreadsheet engine the Cellwise app uses.
| A | |
|---|---|
| 1 | |
| 2 | [email protected] |
| 3 | [email protected] |
| 4 | [email protected] |
| 5 | [email protected] |
| 6 | [email protected] |
| 7 | [email protected] |
| 8 | not provided |
Method 1: TEXTAFTER (Excel 365 and 2021+)
This is a list of webinar signups. TEXTAFTER returns the text after a delimiter, so the delimiter is simply "@". It is the shortest and clearest option if everyone who opens the file has Excel 365, Excel 2021 or later, or Excel for the web.
Result: northwind.com
northwind.com from [email protected].
Method 2: MID and FIND (every version)
FIND gives the position of the @. MID starts one character after it and takes the rest. Using LEN(A2) as the length is a safe way to say "to the end", since MID stops at the last character anyway.
Pick this when the file goes to people on Excel 2019 or older, or to Google Sheets users.
Result: mail.fabrikam.co.uk
mail.fabrikam.co.uk: everything after the @, subdomain included.
Clean the result: case and spaces
Pasted lists often carry stray spaces, and " contoso.com" with a space is a different value from "contoso.com" to COUNTIF, UNIQUE and Remove Duplicates. Excel itself ignores case when it compares text, but Power Query, mail platforms and databases often do not, and mixed case looks messy in a report. TRIM removes leading and trailing spaces, LOWER makes the case consistent. Clean before you count or deduplicate.
Result: contoso.com
contoso.com, lowercased from [email protected].
Handle rows without an @
Real lists contain "not provided", phone numbers and typos. TEXTAFTER returns #N/A and FIND returns #VALUE! when there is no @. IFERROR swaps the error for a label you can filter on.
Result: No email
No email: A8 says "not provided", so there is no @ to split on.
Count signups per domain
You do not need a domain column just to count one company. COUNTIF with a wildcard matches any address ending in that domain. Including the @ in the pattern stops "northwind.com" from also matching "mynorthwind.com". COUNTIF ignores case.
For a full table of domains and counts, extract the domains into a column, then use =UNIQUE(B2:B8) next to =COUNTIF(B2:B8,D2#) in Excel 365, or a PivotTable in any version.
Result: 2
2 signups from northwind.com: Priya and the sales inbox.
Company name only, and the subdomain gotcha
To get "northwind" without ".com", take the text before the first dot of the domain: =TEXTBEFORE(TEXTAFTER(A2,"@"),"."). That works for simple domains but returns "mail" for [email protected]. With subdomains and two-part endings like .co.uk, there is no reliable formula; check those rows by hand.
Flash Fill is another quick route for a one-off list: type the domain for the first row in the next column, then press Ctrl+E. It does not update when the emails change, so use a formula for lists that grow.
Common mistakes
Using RIGHT with a fixed length
=RIGHT(A2,13) only works for domains with exactly 13 characters. Compute the length: =RIGHT(A2,LEN(A2)-FIND("@",A2)).
Counting the same company twice
"contoso.com" and "contoso.com " with a trailing space are different values to UNIQUE and COUNTIF. Wrap the extraction in LOWER(TRIM(...)) before counting.
COUNTIF pattern without the @
"*northwind.com" also counts addresses at mynorthwind.com. Use "*@northwind.com".
Assuming gmail.com means a company
Free providers like gmail.com, outlook.com and yahoo.com are personal addresses. Flag them separately in B2B lists, for example with =IF(OR(B2="gmail.com",B2="outlook.com"),"Personal","Business").
FAQ
How do I get everything after the @ in Excel?
Use =TEXTAFTER(A2,"@") in Excel 365 or 2021+, or =MID(A2,FIND("@",A2)+1,LEN(A2)) in any version.
How do I extract the username from an email in Excel?
Take the text before the @: =TEXTBEFORE(A2,"@") in Excel 365, or =LEFT(A2,FIND("@",A2)-1) in any version.
Can Flash Fill extract email domains?
Yes. Type the first domain next to the first email, press Ctrl+E, and Excel fills the rest. The results are static values, so rerun it when the list changes.
How do I count emails by domain in Excel?
For one domain, use =COUNTIF(A2:A100,"*@domain.com"). For all domains, extract them into a column and use a PivotTable or UNIQUE with COUNTIF.
Why does my domain formula return #VALUE!?
FIND returns #VALUE! when the cell has no @ at all, such as a blank, a name or "not provided". Wrap the formula in IFERROR, or filter those rows out first.
Functions used
TEXTAFTERText after a delimiterTEXTBEFOREText before a delimiterMIDCharacters from the middleFINDPosition of text (case-sensitive)LENLength of textLOWERall lowercaseTRIMRemoves extra spacesIFERRORFallback when a formula errorsCOUNTIFCounts cells that matchRIGHTCharacters from the endLEFTCharacters from the start
Related guides
- How to extract text after a character in Excel
- How to extract text before a character in Excel
- How to remove spaces in Excel
- How to count unique values in Excel
- How to separate first and last name in Excel
- How to extract numbers from a string in Excel
- Excel dates not sorting correctly: how to fix it
Updated