Conditional formatting depending on different strings of text

mbk0523

New Member
Joined
Aug 29, 2012
Messages
25
Office Version
  1. 365
Platform
  1. Windows
Hi,

I have a list of email addresses in which I want to highlight ones that contain certain words from a separate list. For example, I want to highlight any email addresses where the words "info" or "hello" or "feedback" come before the "@", in situations where it's just that word (info@_____.com) and where it appears in a string (compay.info@____.com).

I also want to do the same with email addresses where certain words appear after the "@". Let's say I want to remove "@genericcompany.com" and any ".gov" and ".org" email addresses.

Thanks for the help!
 

Excel Facts

Which Excel functions can ignore hidden rows?
The SUBTOTAL and AGGREGATE functions ignore hidden rows. AGGREGATE can also exclude error cells and more.
This seems to do what you're looking for, though it's pretty clunky.
Book1
BCDEFGH
2crusader@genericcompany.comTRUEKeywords
3feedback@me.comTRUEinfo
4geeber@verizon.orgTRUEhello
5mike@optonline.netFALSEfeedback
6info@icloud.comTRUEgenericcompany.com
7jaarnial@gmail.govTRUE.gov
8kaiser@aol.comFALSE.org
9kourai@yahoo.comFALSE
10mbrown@aol.comFALSE
11neonatus@hotmail.comFALSE
12research@icloud.comFALSE
13yzheng@aol.comFALSE
Sheet1
Cell Formulas
RangeFormula
C2:C13C2=OR(ISNUMBER(FIND($H$3,B2)),ISNUMBER(FIND($H$4,B2)),ISNUMBER(FIND($H$5,B2)),ISNUMBER(FIND($H$6,B2)),ISNUMBER(FIND($H$7,B2)),ISNUMBER(FIND($H$8,B2)))
 

Attachments

  • 1729277905015.png
    1729277905015.png
    159.7 KB · Views: 2
Upvote 0
Thanks, this is helpful. Is there no way to do it more efficiently? What if the keywords in column H is 50 items long...?
 
Upvote 0
Try like this. It assumes no blank cells within the keywords list.

24 10 21.xlsm
BCH
1
2crusader@genericcompany.comKeywords
3feedback@me.cominfo
4geeber@verizon.orghello
5mike@optonline.netfeedback
6info@icloud.comgenericcompany.com
7jaarnial@gmail.gov.gov
8kaiser@aol.com.org
9kourai@yahoo.com
10mbrown@aol.com
11neonatus@hotmail.com
12research@icloud.com
13yzheng@aol.com
Highlight
Cells with Conditional Formatting
CellConditionCell FormatStop If True
B2:B13Expression=COUNT(SEARCH($H$3:$H$8,B2))textNO
 
Upvote 0
Try like this.
Sorry, I had not read your requirements carefully enough. Try this one instead. Note that I have tried to include instances (eg rows 10 & 11) where a country code might be added at the end after things like .com or .gov etc. Is that what you would want?

24 10 21.xlsm
BCHI
1
2crusader@genericcompany.comBeforeAfter
3feedback@me.cominfogenericcompany.com
4geeber@verizon.orghello.gov
5mike@optonline.netfeedback.org
6info@icloud.comhotmail.com
7jaarnial@gmail.gov
8kaiser@aol.com
9kourai@yahoo.com
10mbrown@abcd.gov.uk
11neonatus@hotmail.com.au
12research@icloud.com
13hello.you@aol.info.com
Highlight (2)
Cells with Conditional Formatting
CellConditionCell FormatStop If True
B2:B13Expression=OR(COUNT(SEARCH("."&H$3:H$5&"@","."&B2)),COUNT(SEARCH("@*"&I$3:I$6&".*",B2&".")))textNO
 
Upvote 0
Merch Totals.xlsx
ABCDEFG
2crusader@genericcompany.com
3feedback@me.cominfo
4geeber@verizon.orghello
5mike@optonline.netfeedback
6info@icloud.comgenericcompany.com
7jaarnial@gmail.gov.gov
8kaiser@aol.com.org
9kourai@yahoo.comhotmail.com
10mbrown@abcd.gov.uk
11neonatus@hotmail.com.au
12research@icloud.com
13hello.you@aol.info.com
Sheet1
Cells with Conditional Formatting
CellConditionCell FormatStop If True
A2:A100Expression=SUMPRODUCT(COUNTIF($A2,"*"&$G$3:$G$9&"*"))>0textNO
 
Upvote 0
@MARZIOTULLIO
I'm not sure if (like I did initially) you have initially missed these requirements?
highlight any email addresses where the words "info" or "hello" or "feedback" come before the "@", in situations where it's just that word (info@_____.com) and where it appears in a string (compay.info@____.com).

I also want to do the same with email addresses where certain words appear after the "@". Let's say I want to remove "@genericcompany.com" and any ".gov" and ".org" email addresses.

Below I have used your formula and, by my reading of the conditions, none of the items in column A should be highlighted.

24 10 21.xlsm
ABCDEFG
1
2geeber@verizon.organisation.com
3mike@infoline.netinfo
4zinform@icloud.comhello
5kaiser@aol.comgenericcompany.com
6new.organics@yahoo.comxxx
7tom.govant@abc.com.gov
8research@icloud.com.org
9col.chellox@aol.comhotmail.com
Highlight (3)
Cells with Conditional Formatting
CellConditionCell FormatStop If True
A2:A9Expression=SUMPRODUCT(COUNTIF($A2,"*"&$G$3:$G$9&"*"))>0textNO
 
Upvote 0
Book1
ABCDEFGHI
2geeber@verizon.organisation.comTRUEorg
3mike@infoline.netTRUEinfoinfo
4zinform@icloud.comTRUEhelloinfo
5kaiser@aol.comFALSEgenericcompany.com
6new.organics@yahoo.comTRUExxxorg
7tom.govant@abc.comTRUE.govgov
8research@icloud.comFALSE.org
9colchellox@aol.comTRUEhotmail.comhello
Sheet1
Cell Formulas
RangeFormula
D2:D9D2=SUMPRODUCT(COUNTIF(A2,"*"&$G$3:$G$9&"*"))>0
 
Upvote 0
@MARZIOTULLIO
I'm not sure what post #8 is about? As far as I can see it simply reinforces my point.

Take row 7 as an example. Cell A7 is not a ".gov" email address even though it contains the characters ".gov" and in any case the ".gov" in that cell does not come after the "@" symbol as outlined in post #1

Take row 3 as another example. Your formula says TRUE because it contains the text "info" but the OP wanted highlighted if that text came before the "@" symbol and was by itself, or preceded by a ".', as shown in post #1

Anyway, I guess the OP will confirm one way or the other at some point.
 
Upvote 0

Forum statistics

Threads
1,224,818
Messages
6,181,152
Members
453,021
Latest member
Justyna P

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