Check if cell contains data in another range

shep23

New Member
Joined
Dec 15, 2014
Messages
4
Hi,

I need to check a bunch of domains on a daily basis that cold be suspicious (the company I work for checks tenants, and sometimes they attempt to defraud us by setting up a domain for a bogus employer)

To save time I don't want to check certain pre-approved domains, eg police.uk, gov.uk - the problem I have is that the email domain sometimes comes to me as a subdomain, for example, london.police.uk, not just the top-level domain of police.uk

So on sheet 1 I could have a list of domains like this....

metoffice.gov.uk
charliesofficesupplies.com
london.police.uk

And on sheet 2 i have
police.uk
gov.uk

How do I return if a value on sheet 1 contains the domain name in the range on sheet 2 ? So a YES for domains 1 & 3 and a no for domain 2 ?

I've tried using a wildcard vlookup, without success.

Thanks in advance,
Sheps
 

Excel Facts

Test for Multiple Conditions in IF?
Use AND(test, test, test, test) or OR(test, test, test, ...) as the logical_test argument of IF.
Sheps,

Sheet 1 data starts in Column A1
Sheet 2 data I put in a named range "nr_GoodDomain"

I will "build" up to the answer

Get the number of "."
Code:
B1 =LEN(A1)-LEN(SUBSTITUTE(A1,".",""))

Substitute the second to last "." If there is only one ".", it will cause an error. Handel that at the end. The domain typically will not have the pipe "|", so make that the character to find.
Code:
C1 =SUBSTITUTE(A1,".","|",B1-1)

Get the text after "|".
Code:
D1  =MID(C1,FIND("|",C1)+1,99)

Combine
Code:
E1 =TRIM(IFERROR(MID(SUBSTITUTE(A1,".","|",LEN(A1)-LEN(SUBSTITUTE(A1,".",""))-1),FIND("|",SUBSTITUTE(A1,".","|",LEN(A1)-LEN(SUBSTITUTE(A1,".",""))-1))+1,99),A1))

Finally make the match to the good domains

Code:
F1  =IF(ISERROR(VLOOKUP(E1,nr_GoodDomain,1,FALSE)),"NO","YES")

Tubal
 
Upvote 0
Tubal - you are a hero !

Works like a charm - I'm in the UK so a few of my domains are @example.uk.com , @example.co.uk etc which the formula couldn't account for, but I've worked around this with a nested IF and it's perfect.

Thanks again,

Sheps
 
Upvote 0

Forum statistics

Threads
1,207,402
Messages
6,078,268
Members
446,324
Latest member
JKamlet

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