You are here:

Excel/conditional formatting

Advertisement


Question
Hi Tom, sumif with * worked fine thanks

I now have a problem with conditional formatting.  I have two columns of figures, and I need to colour the cells in one of the columns red or green, depending on whether the values are higher or lower than the corresponding values in the other column eg.

100     200    Because 200 is greater than 100, I would want it to be red.

200     100    because 100 is less than 200, I want it to be green.

Can conditional formatting do this please?

Thanks

Gail

Answer
Gail,

Say your data is in A2:B300 and you want to color cells in column B based on their relationship to column A in the same row.

Select B2:B300 with B2 as the active cell.

Open conditional formatting

then New Rule

then Use a formula to determine which cells to format

Under Format values where this formula is true; in the text box put in

=$B2>$A2

click the format button and choose Fill, then choose Red and click OK, then OK.  

Now repeat:  

Open conditional formatting

then New Rule

then Use a formula to determine which cells to format

Under Format values where this formula is true; in the text box put in

=$B2<$A2

click the format button and choose Fill, then choose Green and click OK, then OK

That worked for me.

Make your formula appropriate for the Active Cell.  Use the $ sign to fix any references that must not change.  In the example I fixed column B and column A.  I let the row remain as a relative rather than fixed reference.  So in cell B3 the formula would automatically be adjusted to

=$B3>$A3    

This was tested and worked for me.

--
Regards,
Tom Ogilvy  
About Excel
This topic answers questions related to Microsoft Excel spreadsheet (or workbook) stand-alone or Mircrosoft Office Excel including Excel 2003, Excel 2007, Office 2000, and Office XP. You can get Excel help on Excel formulas(or functions), Excell macros, charting in Excel, advanced features, and the general use of Excel. This does not provide a general Excel tutorial nor the basics of using a spreadsheet. It provides specific answers to using Microsoft Excel only. If you do not see your Excel question answered in this area then please ask an Excel question here

Excel

All Answers


Answers by Expert:


Ask Experts

Volunteer


Tom Ogilvy

Expertise

Selected as an Excel MVP by Microsoft since 1999. Answering Excel questions in Allexperts since its inception in 2001. Able to answer questions on almost all aspects of Excel's internal capabilities. If seeking a VBA solution, please specify that in your question itself so I give you the answer you want. [Excel has weak protection - if you are distributing an application, I don't answer questions on how to protect your project from your users.]

Experience

Extensive experience.

Education/Credentials
Master of Science (MS) degree Operations Research (ORSA)

Awards and Honors
Microsoft MVP in Excel.

©2016 About.com. All rights reserved.