Conditional Fomatting - IF statements for string

Dave_P_C

New Member
Joined
Nov 9, 2006
Messages
37
Hello,

I use Excel 2007

In a spreadsheet I want to be able to set different conditional formatting based on 2 situations.

a) If the string "present" is in cells B2 to I2 format the row pale green
b) If the string "P" is in cell J2 format the row dark green

I have tried to achieve this by using conditional formatting as follows: -

a) =IF($B2:$I2="present",TRUE,FALSE) ---> Format pale green
b) =IF($J1="P",TRUE,FALSE) --> Format dark greeen

The problems I have are that if the string "present" is in any cell after column B the row is not getting formatted in pale green and if the string "P" is in column J the row is not getting formatted dark green (unless the value "present" is in either not on that row or in a column after B.

Conditional formatting b) should superseed conditional formatting a)

Please note - in the actual spreadsheet the string "present" in clolumns B to I is determined from a formula looking up a value on another sheet..

A very cut-down example of how the spreadsheet

Excel Workbook
ABCDEFGHIJ
1SystemB01B02B03B04B05B06B07B08Setup
2A11presentnot presentnot presentnot presentnot presentnot presentnot presentnot presentP
3A12not presentnot presentnot presentnot presentnot presentnot presentnot presentnot present
4A13not presentnot presentnot presentnot presentnot presentnot presentnot presentnot present
5A14not presentnot presentpresentpresentnot presentnot presentnot presentnot presentP
6A15not presentnot presentnot presentnot presentnot presentnot presentnot presentnot present
7A16not presentnot presentnot presentpresentnot presentnot presentnot presentnot present
Sheet1
Excel 2007



Can anyone advise how to fix this issue ?

Thank you.
 

Excel Facts

How can you automate Excel?
Press Alt+F11 from Windows Excel to open the Visual Basic for Applications (VBA) editor.
If condition b) is to supercede condition a), then untick the Stop If True in condition a), or move condition b) to be before condition a).
 
Upvote 0
Excel Workbook
ABCDEFGHIJK
1SystemB01B02B03B04B05B06B07B08SetupJust present?
2A11presentnot presentnot presentnot presentnot presentnot presentnot presentnot presentPTRUE
3A12not presentnot presentnot presentnot presentnot presentnot presentnot presentnot presentFALSE
4A13not presentnot presentnot presentnot presentnot presentnot presentnot presentnot presentFALSE
5A14not presentnot presentpresentpresentnot presentnot presentnot presentnot presentPTRUE
6A15not presentnot presentnot presentnot presentnot presentnot presentnot presentnot presentFALSE
7A16not presentnot presentnot presentpresentnot presentnot presentnot presentnot presentTRUE
8
Sheet1
Excel 2007
Cell Formulas
RangeFormula
K2=COUNTIF(B2:I2,"present")>0
 
Upvote 0
Hi all,

Thank you for your replies.

GlennUK - I did not have Stop If True selected but the conditions were still not applying correctly.

jim may / jason_b75 - I have used the formula =COUNTIF($B2:$I2,"present") and got it to work.

Part of the issue I had was that I had "Format as table" selected on the sheet and this seemed to superseed anything else.

Having disabled that and used the formulas provided it now works.

Thank you very much.
 
Upvote 0

Forum statistics

Threads
1,224,545
Messages
6,179,432
Members
452,915
Latest member
hannnahheileen

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