Matching specific email address domains from string

Hughesy52

New Member
Joined
Jun 14, 2024
Messages
4
Office Version
  1. 365
Platform
  1. Windows
Hi.

We have hundreds of users with at least 8 different proxy addresses/aliases. They cover various email domains, with a mixture of firstname.lastname@domain or PIN@domain.

One example is Joe Bloggs, who has these email addresses associated with this account:
joe.bloggs@aaa.com,joe.bloggs@bbb.aaa.com,joe.bloggs@ccc.com,11111@aaa.com,11111@bbb.aaa.com,11111@ccc.com

Sue Smith may have just a subset of these:
sue.smith@aaa.com,sue.smith@bbb.aaa.com,22222@aaa.com,22222@bbb.aaa.com

1718892705304.png


How would I check each user against what domains they have associated with their accounts? It has been driving me potty. I could run PowerShell to query each user and have each domain as a NoteProperty and perform a regex search on the proxyAddress, but I thought the powers of Excel would be much quicker.

I am using Office 365.

Thanks in advance,

Hughesy52
 

Attachments

  • 1718891880645.png
    1718891880645.png
    7.9 KB · Views: 3
  • 1718892196535.png
    1718892196535.png
    7.7 KB · Views: 3
  • 1718892610295.png
    1718892610295.png
    7.8 KB · Views: 3

Excel Facts

Remove leading & trailing spaces
Save as CSV to remove all leading and trailing spaces. It is faster than using TRIM().
This seems to do it.

EXCEL
ABCDEFG
1proxyAddressfirst.last@aaa.comfirst.last@bbb.aaa.comfirst.last@ccc.comPIN@aaa.comPIN@bbb.aaa.comPIN@ccc.com
2joe.bloggs@aaa.com,joe.bloggs@bbb.aaa.com,joe.bloggs@ccc.com,11111@aaa.com,11111@bbb.aaa.com,11111@ccc.comYesYesYesYesYesYes
3sue.smith@aaa.com,sue.smith@bbb.aaa.com,22222@aaa.com,22222@bbb.aaa.comYesYesNoYesYesNo
Sheet2
Cell Formulas
RangeFormula
B2:B3B2=CHOOSE(OR(First.Last(A2)*SCAN("",TEXTSPLIT(A2,,","),LAMBDA(s,c,TEXTAFTER(c,"@")="aaa.com")))+1,"No","Yes")
C2:C3C2=CHOOSE(OR(First.Last(A2)*SCAN("",TEXTSPLIT(A2,,","),LAMBDA(s,c,TEXTAFTER(c,"@")="bbb.aaa.com")))+1,"No","Yes")
D2:D3D2=CHOOSE(OR(First.Last(A2)*SCAN("",TEXTSPLIT(A2,,","),LAMBDA(s,c,TEXTAFTER(c,"@")="ccc.com")))+1,"No","Yes")
E2:E3E2=CHOOSE(OR(SCAN("",TEXTSPLIT(A2,,","),LAMBDA(s,c,ISNUMBER(TEXTBEFORE(c,"@")+0)))*SCAN("",TEXTSPLIT(A2,,","),LAMBDA(s,c,TEXTAFTER(c,"@")="aaa.com")))+1,"No","Yes")
F2:F3F2=CHOOSE(OR(SCAN("",TEXTSPLIT(A2,,","),LAMBDA(s,c,ISNUMBER(TEXTBEFORE(c,"@")+0)))*SCAN("",TEXTSPLIT(A2,,","),LAMBDA(s,c,TEXTAFTER(c,"@")="bbb.aaa.com")))+1,"No","Yes")
G2:G3G2=CHOOSE(OR(SCAN("",TEXTSPLIT(A2,,","),LAMBDA(s,c,ISNUMBER(TEXTBEFORE(c,"@")+0)))*SCAN("",TEXTSPLIT(A2,,","),LAMBDA(s,c,TEXTAFTER(c,"@")="ccc.com")))+1,"No","Yes")


Here is the code for the named Lambda 'First.Last'.

Excel Formula:
=LAMBDA(txt,SCAN("",TEXTSPLIT(txt,,","),LAMBDA(s,c,TEXTJOIN(".",,SCAN("",TEXTSPLIT(TEXTBEFORE(c,"@"),"."),LAMBDA(s,c,"#")))))="#.#")
 
Upvote 0
This seems to do it.

EXCEL
ABCDEFG
1proxyAddressfirst.last@aaa.comfirst.last@bbb.aaa.comfirst.last@ccc.comPIN@aaa.comPIN@bbb.aaa.comPIN@ccc.com
2joe.bloggs@aaa.com,joe.bloggs@bbb.aaa.com,joe.bloggs@ccc.com,11111@aaa.com,11111@bbb.aaa.com,11111@ccc.comYesYesYesYesYesYes
3sue.smith@aaa.com,sue.smith@bbb.aaa.com,22222@aaa.com,22222@bbb.aaa.comYesYesNoYesYesNo
Sheet2
Cell Formulas
RangeFormula
B2:B3B2=CHOOSE(OR(First.Last(A2)*SCAN("",TEXTSPLIT(A2,,","),LAMBDA(s,c,TEXTAFTER(c,"@")="aaa.com")))+1,"No","Yes")
C2:C3C2=CHOOSE(OR(First.Last(A2)*SCAN("",TEXTSPLIT(A2,,","),LAMBDA(s,c,TEXTAFTER(c,"@")="bbb.aaa.com")))+1,"No","Yes")
D2:D3D2=CHOOSE(OR(First.Last(A2)*SCAN("",TEXTSPLIT(A2,,","),LAMBDA(s,c,TEXTAFTER(c,"@")="ccc.com")))+1,"No","Yes")
E2:E3E2=CHOOSE(OR(SCAN("",TEXTSPLIT(A2,,","),LAMBDA(s,c,ISNUMBER(TEXTBEFORE(c,"@")+0)))*SCAN("",TEXTSPLIT(A2,,","),LAMBDA(s,c,TEXTAFTER(c,"@")="aaa.com")))+1,"No","Yes")
F2:F3F2=CHOOSE(OR(SCAN("",TEXTSPLIT(A2,,","),LAMBDA(s,c,ISNUMBER(TEXTBEFORE(c,"@")+0)))*SCAN("",TEXTSPLIT(A2,,","),LAMBDA(s,c,TEXTAFTER(c,"@")="bbb.aaa.com")))+1,"No","Yes")
G2:G3G2=CHOOSE(OR(SCAN("",TEXTSPLIT(A2,,","),LAMBDA(s,c,ISNUMBER(TEXTBEFORE(c,"@")+0)))*SCAN("",TEXTSPLIT(A2,,","),LAMBDA(s,c,TEXTAFTER(c,"@")="ccc.com")))+1,"No","Yes")


Here is the code for the named Lambda 'First.Last'.

Excel Formula:
=LAMBDA(txt,SCAN("",TEXTSPLIT(txt,,","),LAMBDA(s,c,TEXTJOIN(".",,SCAN("",TEXTSPLIT(TEXTBEFORE(c,"@"),"."),LAMBDA(s,c,"#")))))="#.#")
Hi Irobbo314. Thanks so much for your reply. I shall give it a go in a short while.
 
Upvote 0
This seems to do it.

EXCEL
ABCDEFG
1proxyAddressfirst.last@aaa.comfirst.last@bbb.aaa.comfirst.last@ccc.comPIN@aaa.comPIN@bbb.aaa.comPIN@ccc.com
2joe.bloggs@aaa.com,joe.bloggs@bbb.aaa.com,joe.bloggs@ccc.com,11111@aaa.com,11111@bbb.aaa.com,11111@ccc.comYesYesYesYesYesYes
3sue.smith@aaa.com,sue.smith@bbb.aaa.com,22222@aaa.com,22222@bbb.aaa.comYesYesNoYesYesNo
Sheet2
Cell Formulas
RangeFormula
B2:B3B2=CHOOSE(OR(First.Last(A2)*SCAN("",TEXTSPLIT(A2,,","),LAMBDA(s,c,TEXTAFTER(c,"@")="aaa.com")))+1,"No","Yes")
C2:C3C2=CHOOSE(OR(First.Last(A2)*SCAN("",TEXTSPLIT(A2,,","),LAMBDA(s,c,TEXTAFTER(c,"@")="bbb.aaa.com")))+1,"No","Yes")
D2:D3D2=CHOOSE(OR(First.Last(A2)*SCAN("",TEXTSPLIT(A2,,","),LAMBDA(s,c,TEXTAFTER(c,"@")="ccc.com")))+1,"No","Yes")
E2:E3E2=CHOOSE(OR(SCAN("",TEXTSPLIT(A2,,","),LAMBDA(s,c,ISNUMBER(TEXTBEFORE(c,"@")+0)))*SCAN("",TEXTSPLIT(A2,,","),LAMBDA(s,c,TEXTAFTER(c,"@")="aaa.com")))+1,"No","Yes")
F2:F3F2=CHOOSE(OR(SCAN("",TEXTSPLIT(A2,,","),LAMBDA(s,c,ISNUMBER(TEXTBEFORE(c,"@")+0)))*SCAN("",TEXTSPLIT(A2,,","),LAMBDA(s,c,TEXTAFTER(c,"@")="bbb.aaa.com")))+1,"No","Yes")
G2:G3G2=CHOOSE(OR(SCAN("",TEXTSPLIT(A2,,","),LAMBDA(s,c,ISNUMBER(TEXTBEFORE(c,"@")+0)))*SCAN("",TEXTSPLIT(A2,,","),LAMBDA(s,c,TEXTAFTER(c,"@")="ccc.com")))+1,"No","Yes")


Here is the code for the named Lambda 'First.Last'.

Excel Formula:
=LAMBDA(txt,SCAN("",TEXTSPLIT(txt,,","),LAMBDA(s,c,TEXTJOIN(".",,SCAN("",TEXTSPLIT(TEXTBEFORE(c,"@"),"."),LAMBDA(s,c,"#")))))="#.#")
Hi Irobbo314. The formulae for E, F & G work perfectly, thank you. I have tried the formula for cell B, C & D and I seem to be getting a #NAME error near the end.

Any ideas?

1718968173247.png
 

Attachments

  • 1718967432865.png
    1718967432865.png
    39.2 KB · Views: 2
Upvote 0
You need to copy and paste that formula I posted at the bottom as a defined name. Like if you were naming a range. Then give it the name First.Last
 
Upvote 0
Ah ok I see, thank you. I think I'm a bit scuppered here. I've been editing the spreadsheet online and it will accept the formulas, but I can't define names. And when I edit the spreadsheet locally and attempt to add the formulas, I keep running into this error because I don't think it understand one of them.

1718984048211.png


1718984183658.png


I think I've got an older version of Excel on my laptop, so I'll try and get it updated.

Thank you for all your help on this.
 
Upvote 0

Forum statistics

Threads
1,220,965
Messages
6,157,119
Members
451,398
Latest member
rjsteward

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