Question

I am trying to highlight a cell (or possibly the entire row) if a cell contains a value less than 0 or #N/A. Either condition would invoke a bold red text with default background color (white).

Columns are:

Column A Column K Column L Column M Column N Column O File 1 File 1 File 2 Miles File 3
Equip # Ending Odometer Ending Odometer Driven Gallons Fuel MPG (Key) (Calculated) (Calculated) =Kn - Ln =Mn / Nn (Where lower case n indicates row number)

File 1 is the master file and I use VLOOKUP to include data from files 2 and 3, so File 2 Ending Odometer and File 3 Gallons Fuel may have #N/A or 0. Either calculated field may contain 0 or #N/A. If the VLOOKUP used in Columns L or N does not find a match with the value in Column A, #N/A is displayed.

I apologize if all this background information has confused anyone.

My question is how can I set a Conditional Background for values in columns L, M, N or O if the value in Ln or Mn or Nn or On is less than 0 or the value in Ln or Mn or Nn or On is #N/A.

One other thing, I know nothing about VBA or macros, so if your solution involves either, you will have to include all coding, etc.

Thank you for your assistance.

skp8122005

Was it helpful?

Solution

Disregard my comment to your question, this should do what you want. Create 4 new conditional formatting rules and select the "Use a formula to determine which cells to format" options. Use the following formulas:

    =IF(ISERROR($L1),TRUE,IF($L1<0,TRUE))
    =IF(ISERROR($M1),TRUE,IF($M1<0,TRUE))
    =IF(ISERROR($N1),TRUE,IF($N1<0,TRUE))
    =IF(ISERROR($O1),TRUE,IF($O1<0,TRUE))

Make them all apply to $L:$O and check the "Stop If True" box. This will highlight the entire row for you.

OTHER TIPS

You can do this with a single condition, i.e.

=IF(COUNTIF($L1:$O1,NA()),1,IF(COUNTIF($L1:$O1,"<0"),1))

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top