Extract company name from email address with multiple values after @

candymycandy

New Member
Joined
Jun 14, 2022
Messages
17
Office Version
  1. 365
Platform
  1. Windows
Hi,

I have a formula that extracts the domain/company name from an email address after the @ sign when the format is BobSmith@Company.com
=MID(LEFT(D748,FIND(".",D748,FIND("@",D748))-1),FIND("@",D748)+1,99)

Is it possible to do this to extract the domain/company when the email address is in the format BobSmith@UK.Company.com please?

Thanks in advance for any help!
 

Excel Facts

Square and cube roots
The =SQRT(25) is a square root. For a cube root, use =125^(1/3). For a fourth root, use =625^(1/4).
Upvote 0
Can you also have domains like Company.co.uk
 
Upvote 0
Couple of options I have played with before:

1st Option is not very dynamic:
Book1
AB
1EmailCompany
2BobSmith@Company1.comCompany1
3BobSmith@UK.Company2.comCompany2
4BobSmith@UK.Company123.co.ukCompany123
5BobSmith@Company-951.UK.comCompany-951
6BobSmith@eu.Company-951.UK.comCompany-951
Sheet1
Cell Formulas
RangeFormula
B2:B6B2=LET( data,TEXTAFTER(A2:A6,"@"), xml,"<t><s>"&SUBSTITUTE(data,".","</s><s>")&"</s></t>", f,IFERROR(FILTERXML(xml,"//s["&SEQUENCE(,10)&"]"),""), m,MAP(f,LAMBDA(x,IF(LEN(x)=2,"",IF(LOWER(x)="com","",x)))), BYROW(m,LAMBDA(x,FILTER(x,x<>""))))
Dynamic array formulas.


Second option lets you have a list where you can exclude parts of the email address by dropping the value to remove in column K and the pipe symbol in column L:
Book1
EFGHIJKL
1EmailCompanyExclude list
2BobSmith@Company1.comCompany1com|
3BobSmith@UK.Company2.comCompany2uk|
4BobSmith@UK.Company123.co.ukCompany123co|
5BobSmith@Company-951.UK.comCompany-951eu|
6BobSmith@eu.Company-951.UK.comCompany-951
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
Sheet1
Cell Formulas
RangeFormula
F2:F6F2=LET(rng,A2:A6,f,K2:K26,r,L2:L26, BYROW(rng,LAMBDA(x,LET(t,DROP(TEXTSPLIT(x,{".","@"},,TRUE),,1),SUBSTITUTE(TEXTJOIN("",TRUE,IFNA(XLOOKUP(t,f,r),t)),"|","")))))
Dynamic array formulas.
 
Upvote 0
Couple of options I have played with before:

1st Option is not very dynamic:
Book1
AB
1EmailCompany
2BobSmith@Company1.comCompany1
3BobSmith@UK.Company2.comCompany2
4BobSmith@UK.Company123.co.ukCompany123
5BobSmith@Company-951.UK.comCompany-951
6BobSmith@eu.Company-951.UK.comCompany-951
Sheet1
Cell Formulas
RangeFormula
B2:B6B2=LET( data,TEXTAFTER(A2:A6,"@"), xml,"<t><s>"&SUBSTITUTE(data,".","</s><s>")&"</s></t>", f,IFERROR(FILTERXML(xml,"//s["&SEQUENCE(,10)&"]"),""), m,MAP(f,LAMBDA(x,IF(LEN(x)=2,"",IF(LOWER(x)="com","",x)))), BYROW(m,LAMBDA(x,FILTER(x,x<>""))))
Dynamic array formulas.


Second option lets you have a list where you can exclude parts of the email address by dropping the value to remove in column K and the pipe symbol in column L:
Book1
EFGHIJKL
1EmailCompanyExclude list
2BobSmith@Company1.comCompany1com|
3BobSmith@UK.Company2.comCompany2uk|
4BobSmith@UK.Company123.co.ukCompany123co|
5BobSmith@Company-951.UK.comCompany-951eu|
6BobSmith@eu.Company-951.UK.comCompany-951
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
Sheet1
Cell Formulas
RangeFormula
F2:F6F2=LET(rng,A2:A6,f,K2:K26,r,L2:L26, BYROW(rng,LAMBDA(x,LET(t,DROP(TEXTSPLIT(x,{".","@"},,TRUE),,1),SUBSTITUTE(TEXTJOIN("",TRUE,IFNA(XLOOKUP(t,f,r),t)),"|","")))))
Dynamic array formulas.
thank you, I tried the first one which works but not for company names with only 2 characters. Also I cannot extend it to more than about 150 rows?
 
Upvote 0
How about
Fluff.xlsm
AB
1
2BobSmith@Company.comCompany
3BobSmith@UK.Company.comCompany
4BobSmith@UK.Company.co.ukCompany
5BobSmith@Company.co.ukCompany
6BobSmith@ab.co.ukab
7BobSmith@ab.comcom
Lists
Cell Formulas
RangeFormula
B2:B7B2=LET(s,TEXTSPLIT(TEXTAFTER(A2,"@"),"."),TAKE(FILTER(s,LEN(s)=MAX(LEN(s))),,1))


But you are going to have problems with companies that only have 2 letters.
 
Upvote 0
Solution
thank you, I tried the first one which works but not for company names with only 2 characters. Also I cannot extend it to more than about 150 rows?
The second option might be better for you anyway.

To change the range on both options you would need to edit the 'A2:A6' part
 
Upvote 0
The second option might be better for you anyway.

To change the range on both options you would need to edit the 'A2:A6' part
Thank you, I had changed the range but it came back with a calc error? Thank you for taking the time to help!
 
Upvote 0

Forum statistics

Threads
1,223,952
Messages
6,175,594
Members
452,656
Latest member
earth

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top