Save content
Have you found this content useful? Use the button above to save it to your profile.

Excel Tip: Using conditional formatting to format the whole row

26th Jun 2012
Save content
Have you found this content useful? Use the button above to save it to your profile.

Coloured rowsColour-coding can make it much easier for humans to read a spreadsheet, as our eyes and brains are wired up to treat differences in colour as important. For example, you may colour rows as red, amber or green based upon a status level - possibly, in a stock list, how close an item is to being out of stock.

If you do this, do you do it manually?

Many users know about Conditional Formatting, but do not know how to format whole rows in this way. I, for one, used it for years without knowing how to do this - but it's really simple when you know how.

It involves using Conditional Formatting's formula feature with Excel's ability to fix references using the dollar sign.

Let us take a very simple example of stock, where we wish to show lines with less than five items as red, less than ten items as amber and ten items or over as green.

Assume we have a heading row so the stock data starts at row 2, and the stock level is the last column of the data and is held in column H.

Highlight cells B2 to H1000, or down to whatever row more than covers the number of stock items you might have. Select Conditional Formatting (from the Home ribbon on Excel 2007/2010, or from the Fomat menu on Excel 2003) and select "Use a formula to determine which cells to format" (in 2007/2010) or "Formula is" (in 2003).

2003 and 2007/10 work slightly different in this respect, as 2003 allows you to add up to 3 conditions using the Add button and 2007/10 allows many rules to be added and managed.

The following formulae should be entered as the three conditions in Excel 2003, or as 3 separate rules in 2007/2010. In each case you will determine the format to be used if this condition is true using the Format button next to where you enter the formula. This works very similar to the normal dialogue box you get when formatting cells.

For the red:

Formula         =$H2<5
Format          Fill Red

For the green: 

Formula         =$H2>=10
Format          Fill Green

For the amber:

Formula         =AND($H2>=5,$H2<10)
Format          Fill Orange

(read more on the AND function here, under combining conditions) 

The most important thing to note here is the use of the dollar sign. What we are doing here is fixing the column (H), but leaving the row flexible, so that all cells in the highlighted range, look along their own row to column H to apply the criteria. Also note that you should enter the formula as if you were entering it for the first row of the range - this is why we have entered H2 as row 2 is the top row that we have highlighted.

One other thing to note is that the formula is always preceded by an equals sign, even if it has an equals sign in the criteria. So, if we had wanted to format red when H2 was equal to 5, we would have, rather oddly, entered =$H2=5.

This technique has many applications, and is really simple when you get the hang of it.

If you enjoyed this post, go to the top left corner of the blog, where you can subscribe for regular updates and get your free report "The 5 Excel features that you NEED to know".

Tags:

You might also be interested in

Replies (3)

Please login or register to join the discussion.

avatar
By bethanjones
28th Jun 2012 10:57

thank you

i actually love you for this.  (haven't tried it yet) I knew there must be a way but have never worked it out.  Have just been copying and pasting the format which is limited and causes all sorts of problems when you want to change something - so much so that you avoid making changes because of the hassle.

Thank you.

 

Thanks (0)
avatar
By brian.barrett
14th Jul 2012 02:31

Last Formula may be omitted in later editions

In 2010 (and possibly earlier versions), where you have a number of conditions with the last condition a 'catch-all' type, you may do the following:

- for each condition upto the last one tick the 'Stop if True' box

- for the last condition just enter '=1' [this is always true if it gets to this stage]

You will need to ensure that the conditions are listed downwards (for 2010) in the order that you want them to be performed.  In this case it is only important that the '=1' test is done last.

As the last condition in this scenario is often complicated (it is trying to do the reverse of all the tests above it; and put them into an AND statement), this method may prevent errors and possibly follows purer logic.

Thanks (0)
avatar
By lrmac
14th Jul 2012 10:29

(No subject)

Thanks (0)