Help!! Conditional formatting formula

MichaelRSnow

Active Member
Joined
Aug 3, 2010
Messages
409
I'm not sure why this doesn't work but I'm trying to write 4 conditional formatting formulas but I'm getting multiple results

I want to A) look at cell for a specific value (looking to match 1 or none), could be multiple options in that one cell, if true or false then B) check another cell for one of two values. In my head there are 4 possible outcomes
A) Finds Value and B) Finds Value 1
A) Does not find any Values and B) Finds Value 1
A) Finds Value and B) Finds Value 2
A) Does not finds any Values and B) Finds Value 2

I was using IF(AND(OR with ISNUMBER to match or ISERROR to not match but something isn't right as I'm seeing duplicate results being matched

Excel Formula:
=IF(AND(OR(ISERROR(SEARCH("*One*",A1)),ISERROR(SEARCH("*Two*",A1)),ISERROR(SEARCH("*Three*",A1)),ISERROR(SEARCH("*Four*",A1))),C1="Yes"),1,0)
=IF(AND(OR(ISERROR(SEARCH("*One*",A1)),ISERROR(SEARCH("*Two*",A1)),ISERROR(SEARCH("*Three*",A1)),ISERROR(SEARCH("*Four*",A1))),C1="No"),1,0)
=IF(AND(OR(ISNUMBER(SEARCH("*One*",A1)),ISNUMBER(SEARCH("*Two*",A1)),ISNUMBER(SEARCH("*Three*",A1)),ISNUMBER(SEARCH("*Four*",A1))),C1="Yes"),1,0)
=IF(AND(OR(ISNUMBER(SEARCH("*One*",A1)),ISNUMBER(SEARCH("*Two*",A1)),ISNUMBER(SEARCH("*Three*",A1)),ISNUMBER(SEARCH("*Four*",A1))),C1="No"),1,0)

Example Results, what am I doing wrong?

OneYes
1​
0​
1​
0​
TwoYes
1​
0​
1​
0​
ThreeYes
1​
0​
1​
0​
OneNo
0​
1​
0​
1​
TwoNo
0​
1​
0​
1​
ThreeNo
0​
1​
0​
1​
FourYes
1​
0​
1​
0​
FourNo
0​
1​
0​
1​
FiveYes
1​
0​
0​
0​
FiveNo
0​
1​
0​
0​
Yes
1​
0​
0​
0​
No
0​
1​
0​
0​
 

Excel Facts

Excel Can Read to You
Customize Quick Access Toolbar. From All Commands, add Speak Cells or Speak Cells on Enter to QAT. Select cells. Press Speak Cells.
I see 2 issues with your formulas. First, you don't need the wildcard character with SEARCH. Second, I think the Boolean logic is not quite right. As you noted, there are 4 combinations, making this a binary problem. I'd suggest putting your valid values for the first column in a separate table, making it easier to read and change. This makes the formulas easier too:

Book3
ABCDEFGHIJ
1FirstSecondNot found and NoNot found and yesFound and NoFound and YesValue List
2OneYes0001One
3TwoYes0001Two
4ThreeYes0001Three
5OneNo0010Four
6TwoNo0010
7ThreeNo0010
8FourYes0001
9FourNo0010
10FiveYes0100
11FiveNo1000
Sheet7
Cell Formulas
RangeFormula
E2:E11E2=IF(ISNUMBER(MATCH($A2,$J$2:$J$5,0))*2+($C2="Yes")=0,1,0)
F2:F11F2=IF(ISNUMBER(MATCH($A2,$J$2:$J$5,0))*2+($C2="Yes")=1,1,0)
G2:G11G2=IF(ISNUMBER(MATCH($A2,$J$2:$J$5,0))*2+($C2="Yes")=2,1,0)
H2:H11H2=IF(ISNUMBER(MATCH($A2,$J$2:$J$5,0))*2+($C2="Yes")=3,1,0)


Hope this helps!
 
Upvote 0
I see 2 issues with your formulas. First, you don't need the wildcard character with SEARCH. Second, I think the Boolean logic is not quite right. As you noted, there are 4 combinations, making this a binary problem. I'd suggest putting your valid values for the first column in a separate table, making it easier to read and change. This makes the formulas easier too:

Book3
ABCDEFGHIJ
1FirstSecondNot found and NoNot found and yesFound and NoFound and YesValue List
2OneYes0001One
3TwoYes0001Two
4ThreeYes0001Three
5OneNo0010Four
6TwoNo0010
7ThreeNo0010
8FourYes0001
9FourNo0010
10FiveYes0100
11FiveNo1000
Sheet7
Cell Formulas
RangeFormula
E2:E11E2=IF(ISNUMBER(MATCH($A2,$J$2:$J$5,0))*2+($C2="Yes")=0,1,0)
F2:F11F2=IF(ISNUMBER(MATCH($A2,$J$2:$J$5,0))*2+($C2="Yes")=1,1,0)
G2:G11G2=IF(ISNUMBER(MATCH($A2,$J$2:$J$5,0))*2+($C2="Yes")=2,1,0)
H2:H11H2=IF(ISNUMBER(MATCH($A2,$J$2:$J$5,0))*2+($C2="Yes")=3,1,0)


Hope this helps!
Sorry wasn't absolutely clear in my example, I need the wild cards as the text string in the cell is more than the value I'm looking for, i've updated my example below

Test One TestYes
1​
0​
1​
0​
Test Two TestYes
1​
0​
1​
0​
Test Three TestYes
1​
0​
1​
0​
Test One TestNo
0​
1​
0​
1​
Test Two TestNo
0​
1​
0​
1​
Test Three TestNo
0​
1​
0​
1​
Test Four TestYes
1​
0​
1​
0​
Test Four TestNo
0​
1​
0​
1​
Test Five TestYes
1​
0​
0​
0​
Test Five TestNo
0​
1​
0​
0​
Yes
1​
0​
0​
0​
No
0​
1​
0​
0​
 
Upvote 0
My apologies, I made a couple of errors. First, I stand by my assertion that you don't need the wildcards, but on the other hand, they don't hurt either. For example:

Book3
ABC
15Test One Test6
161
Sheet7
Cell Formulas
RangeFormula
C15C15=SEARCH("One",A15)
C16C16=SEARCH("*One*",A15)


Both ways of writing the function return a positive value which would return TRUE from ISNUMBER.

Second, my formulas did not handle the fact that it's not a full match either. 😞 I still think it's easier to put your values in a list somewhere, so try this instead:

Book3
ABCDEFGHIJ
1FirstSecondNot found and NoNot found and yesFound and NoFound and YesValue List
2One TestYes0001One
3Two TestYes0001Two
4Test ThreeYes0001Three
5Test One TestNo0010Four
6Test TwoNo0010
7Three ThreeNo0010
8Four testYes0001
9FourteenNo0010
10Five testYes0100
11FFF FiveNo1000
Sheet7
Cell Formulas
RangeFormula
E2:E11E2=IF(ISNUMBER(AGGREGATE(14,6,SEARCH($J$2:$J$5,A2),1))*2+($C2="Yes")=0,1,0)
F2:F11F2=IF(ISNUMBER(AGGREGATE(14,6,SEARCH($J$2:$J$5,A2),1))*2+($C2="Yes")=1,1,0)
G2:G11G2=IF(ISNUMBER(AGGREGATE(14,6,SEARCH($J$2:$J$5,A2),1))*2+($C2="Yes")=2,1,0)
H2:H11H2=IF(ISNUMBER(AGGREGATE(14,6,SEARCH($J$2:$J$5,A2),1))*2+($C2="Yes")=3,1,0)
Cells with Conditional Formatting
CellConditionCell FormatStop If True
H2:H11Expression=ISNUMBER(AGGREGATE(14,6,SEARCH($J$2:$J$5,A2),1))*2+($C2="Yes")=3textNO
G2:G11Expression=ISNUMBER(AGGREGATE(14,6,SEARCH($J$2:$J$5,A2),1))*2+($C2="Yes")=2textNO
F2:F11Expression=ISNUMBER(AGGREGATE(14,6,SEARCH($J$2:$J$5,A2),1))*2+($C2="Yes")=1textNO
E2:E11Expression=ISNUMBER(AGGREGATE(14,6,SEARCH($J$2:$J$5,A2),1))*2+($C2="Yes")=0textNO


Also, please update your profile to show what version of Excel you're using. The best answer often depends on what functions you have available to use.
 
Upvote 0

Forum statistics

Threads
1,223,900
Messages
6,175,276
Members
452,629
Latest member
SahilPolekar

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