Conditional formatting using AND statement with Error

rjplante

Well-known Member
Joined
Oct 31, 2008
Messages
569
Office Version
  1. 365
Platform
  1. Windows
I would like to have a cell that will use a multiple condition for cell formatting. I need the cell to check a cell at the top of the column and if the current cell is in error. I currently have the following in the conditional formatting formula field:

=AND(D$4 = "YES", C11=Error)

This does not result in the yellow cell fill formatting being applied to cell C11.

Is it possible to incorporate an AND statement that uses a standard formula along with an Error statement? If so how do I enter it in the conditional formatting formula field?
 

Excel Facts

Add Bullets to Range
Select range. Press Ctrl+1. On Number tab, choose Custom. Type Alt+7 then space then @ sign (using 7 on numeric keypad)
Different errors which set different flags and can be tested with different formulas.
ISERR()
ISERROR()
ISNA()
may be others, can't recall.

Use the appropriate one depending on which error is being set, e.g.

=AND(D$4="YES",ISNA(C11))
 
Upvote 0
Try:
Excel Formula:
=AND(D$4 = "YES", ISERROR(C11))
 
Upvote 0
I have tried all of these options from above:

ISERR()
ISERROR()
ISNA()

and none of the result in the cell C11 being highlighted. Will I have to use a second helper cell to do all of the complex calculations and then return a 1 or 0 for my results, which I can then use in the formula for conditional formatting?

I don't know the best way to proceed.
 
Upvote 0
Can you post some sample data.

MrExcel has a tool called “XL2BB” that lets you post samples of your data that will allow us to copy/paste it to our Excel spreadsheets, so we can work with the same copy of data that you are. Instructions on using this tool can be found here: XL2BB Add-in

Note that there is also a "Test Here” forum on this board. This is a place where you can test using this tool (or any other posting techniques that you want to test) before trying to use those tools in your actual posts.
 
Upvote 0
Maybe D4 is not equal to "YES"

In cases like this break it down

in a blank cell enter

=D$4="YES"

If it says TRUE then the fault lies with the "If error", if it says FALSE then D$4 is not equal to "YES"
 
Last edited:
Upvote 0
Checked cell d4 and value returned True. Formula in cell C11 is:

=IF(VLOOKUP($A11,'Pricing Table'!$B$5:$I$756,C$4,FALSE) = "","",VLOOKUP($A11,'Pricing Table'!$B$5:$I$756,C$4,FALSE))

Here is the section of the spreadsheet from XL2BB


Pricing Template 01-SEP-2021 - TEST.xltm
ABCD
4Quantity2YES
6Component01
7Test 1$286,625 
8Test 2  
9ACCESSORIES01
1048" Wide spool$28,270 
1196" Wide spool$40,565 
Pricing Sheet
Cell Formulas
RangeFormula
B6B6=SUM(B7:B8)
C7:C8,C10:C11C7=IF(VLOOKUP($A7,'Pricing Table'!$B$5:$I$756,C$4,FALSE) = "","",VLOOKUP($A7,'Pricing Table'!$B$5:$I$756,C$4,FALSE))
D7:D8,D10:D11D7=IF(ISERROR($B7*C7),"",IF(OR($A7="",$B7=""),"",$B7*C7))
B9B9=SUM(B10:B18)
Named Ranges
NameRefers ToCells
'Pricing Table'!Parts='Pricing Table'!$B$5:$B$729C10:C11, C7:C8
Parts='Pricing Sheet'!$A$7:$A$692C7:D7
Cells with Conditional Formatting
CellConditionCell FormatStop If True
A10:A18Expression=$BP10<>TRUEtextNO
D4Cellcontains a blank value textNO
C6Expression=MOD(COLUMN(),2)=0textNO
C9:P9Expression=MOD(COLUMN(),2)=0textNO
D4,F4,H4,J4,L4,N4,P4Cell Value="YES"textNO
D4,F4,H4,J4,L4,N4,P4Cell Value="NO"textNO
D301:P301,C294:P300,C275:P291,C273:P273,C252:P258,C238:P250,C229:P236,C226:P227,C222:P223,C219:P220,C215:P216,C212:P213,C210:P210,C206:P208,C201:P204,C196:P199,C191:P194,C189:P189,C186:P187,C182:P184,C179:P180,C176:P177,C169:P174,C161:P167,C158:P159Expression=MOD(COLUMN(),2)=0textNO
C9:P399Expression=AND(D$4="YES",ISNA(C14))textNO
C6:P8Expression=AND(D$4="YES",ISNA(C10))textNO
 
Last edited:
Upvote 0
None of those cells have an error in col C, hence nothing is highlighted. Although the C11 should reflect the 1st row in the applies to range.
Also if you want it to highlight the row you need to use
Excel Formula:
=AND($D$4="YES",ISNA($C6))
 
Upvote 0
Here is an updated section with the error in it.

Pricing Template 01-SEP-2021 - TEST.xltm
ABCD
4Quantity2YES
6Component01
7new entry#N/A 
8Test 2  
9ACCESSORIES01
1048" Wide spool$28,270 
1196" Wide spool$40,565 
Pricing Sheet
Cell Formulas
RangeFormula
B6B6=SUM(B7:B8)
C7:C8,C10:C11C7=IF(VLOOKUP($A7,'Pricing Table'!$B$5:$I$756,C$4,FALSE) = "","",VLOOKUP($A7,'Pricing Table'!$B$5:$I$756,C$4,FALSE))
D7:D8,D10:D11D7=IF(ISERROR($B7*C7),"",IF(OR($A7="",$B7=""),"",$B7*C7))
B9B9=SUM(B10:B18)
Named Ranges
NameRefers ToCells
'Pricing Table'!Parts='Pricing Table'!$B$5:$B$729C10:C11, C7:C8
Parts='Pricing Sheet'!$A$7:$A$692C7:D7
Cells with Conditional Formatting
CellConditionCell FormatStop If True
A10:A18Expression=$BP10<>TRUEtextNO
D4Cellcontains a blank value textNO
C6Expression=MOD(COLUMN(),2)=0textNO
C9:P9Expression=MOD(COLUMN(),2)=0textNO
D4,F4,H4,J4,L4,N4,P4Cell Value="YES"textNO
D4,F4,H4,J4,L4,N4,P4Cell Value="NO"textNO
D301:P301,C294:P300,C275:P291,C273:P273,C252:P258,C238:P250,C229:P236,C226:P227,C222:P223,C219:P220,C215:P216,C212:P213,C210:P210,C206:P208,C201:P204,C196:P199,C191:P194,C189:P189,C186:P187,C182:P184,C179:P180,C176:P177,C169:P174,C161:P167,C158:P159Expression=MOD(COLUMN(),2)=0textNO
C9:P399Expression=AND(D$4="YES",ISNA(C14))textNO
C6:P8Expression=AND(D$4="YES",ISNA(C10))textNO
 
Upvote 0

Forum statistics

Threads
1,214,979
Messages
6,122,550
Members
449,088
Latest member
davidcom

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