Cours-Gratuit
  • Accueil
  • Blog
  • Cours informatique
home icon Cours gratuits » Cours informatique » Cours Bureautique » Cours Excel » Excel courses

EXCEL tutorial on conditional formatting

EXCEL tutorial on conditional formatting
Participez au vote ☆☆☆☆☆★★★★★

Excel Conditional Formatting

Using colour to make data analysis easier

Excel conditional formatting automatically formats cells in your     It’s good to have worksheet if specified criteria are met, giving you a visual aid for        an understanding analysing your data. of Excel formulae

and functions in

These workshop notes are suitable for Excel 2016, 2013 and       Excel before 2010, although some of the techniques are not available in Excel           working through

                                   2010.                                                                                                       this document.

Last updated by Faye Brockwell

28 August 2018

This document and other Excel documents are held online on our website:

University of Brighton Information Services

Contents

                           Introduction 3

                           Predefined conditional formatting 3

Exercise A. Highlighting cells .. 4

Exercise B. Top and Bottom Rules .. 4

                           Clearing conditional formatting . 5

Exercise C. Using Data bars and Colour Scales 6

Exercise D. Using icon sets . 7

                           Using your own rules 8

                                     Rules manager .. 9

                          4.1.1          The rules hierarchy 10

                                    Creating a new conditional formatting rule ..11

Exercise E. Creating a Simple Rule 12

Exercise F. Relative, absolute and mixed referencing refresher 13

Exercise G. Creating a rule using OR 17

Exercise H. Colour coding entire rows ..18

Exercise I. Creating a rule using AND 19

                                     Dates .22

4.3.1    Date format in Excel sheets ..22 4.3.2             Using dates in a formula .22

Exercise J. Using dates in conditional formatting .23

Exercise K. Changing the rules hierarchy 25

               Comparing with cells on another sheet using VLOOKUP .27 4.4.1 Note for using conditional formatting on cells containing formulae .29

                           Filtering using conditional formatting 29

Page | 2                                                                                                                  last update August 2018

                                            Introduction

Excel conditional formatting automatically formats cells in your worksheet if specified criteria are met. For example, you can:

•    Change the text of a cell to red if a project has gone over budget

•    Put a coloured border around cells that are duplicates

•    Change the colour of a row to orange if a project is nearing its deadline

•    Add an icon to highlight any figures that were an improvement on this time last year.

•    Change the colour of the top 10 results in a list to green.

Using conditional formatting gives you a visual aid when analysing your data. You can also filter by colour to easily focus.

                                            Predefined conditional formatting

There are lots of predefined rules you can use for conditional formatting.

To use these, the technique is:

•    Select the area in your worksheet to which you want to apply conditional formatting.

•    On the Home tab, click on the Conditional Formatting icon.

•    Choose the type of conditional formatting you want from the list.

•    Adjust the settings to meet your requirements.

In Excel 2013 and 2016 you can also use Quick Analysis to apply some types of conditional formatting:

•    Select the area in your worksheet to which you want to apply conditional formatting.

•    Click on the Quick Analysis icon  that appears at the bottom right of the selection.

•    Click on the FORMATTING tab in the pop-up window.

•    Choose the type of conditional formatting you want from the suggestions. Hover over each one first to see what the result would be.

•    Adjust the settings to meet your requirements.


The following exercises suggest some applications for some of the pre-defined conditional formats.

Exercise A.

Highlighting cells

1.     Open up the file Highlight cell

2.     Select cells B28 to F35

3.     On the Home tab, click on the Conditional Formatting icon. 

4.     Hover over Highlight Cell Rules.

5.     Click on Between.

6.     Use the boxes to specify that you want to fill cells green if they contain a value between 10% and 15% and click OK.

Exercise B.

Top and Bottom Rules

7.     Using the other areas on the worksheet, experiment with some of the other Highlight Cells Rules available.

1.     Open up the file  Top bottom

2.     Select cells B5 to B26

3.     On the Home tab, click on the Conditional Formatting icon

4.     Hover over Top/bottom rules.

5.     Click on Top 10 items.

6.     Use the boxes to specify that you want to fill cells containing the top 10 items red.

7.     Select cells C5 to C26

8.     On the Home tab, click on the Conditional Formatting

9.     Hover over Top/bottom rules.

10.    Click on Below Average.

11.    Use the boxes to specify that you want to fill cells yellow which contain a figure that is below the average for the selected cells.

 Clearing conditional formatting

To clear conditional formatting:

•    Select the cells containing that have conditional formatting applied.

•    On the Home tab, click on the Conditional Formatting icon

•    Click on Clear Rules

•    Click on Clear Rules from selected cells (or click on Clear Rules from Entire Sheet if you want to get rid of all rules in the worksheet).

Or in Excel 2013 and 2016 you can:

•    Select the cells containing that have conditional formatting applied.

•    Click on the Quick Analysis icon  that appears at the bottom right of the selection.

•    Click on the FORMATTING tab in the pop-up window.

•    Click on the Clear icon.

Exercise C.

Using Data bars and Colour Scales

Data bars appear in each cell of a selected area. The length of the data bar represents the value of the cell relative to the other cells.

Colour scales appear in each cell of a selected range. The colour and shade represent higher and lower values.

1.     Open the file More predefined

2.     Click on the Data Bars worksheet and select the range B4 to G11

3.     On the Home tab, click on the Conditional Formatting

4.     Hover over Data bars and choose one of the options.

5.     Clear the conditional formatting from the sheet.

6.     This time select the range B4 to F11 (excluding the totals).

7.     On the Home tab, click on the Conditional Formatting, hover over Colour scales and choose one of the options.

Data bars and Colour Scales are also available via the Quick Analysis icon  in Excel 2013 and 2016, although the colour selection is limited.

Exercise D.

Using icon sets

Icon sets allow you to classify data into categories by value.

1.     Continue with the More predefined file

2.     Click on the Icon sets worksheet and select the range B4 to B15

3.     On the Home tab, click on the Conditional Formatting

4.     Hover over Icon sets and choose the first option

5.     Note how the icons have been added to the figures.

To set the thresholds for the icons, on the Home tab, click on the Conditional Formatting and click on Manage Rules

6.     Click on the drop down in the Show Formatting Rules for: box and choose This Worksheet. 7.   Click to select the icon set rule and click on Edit Rule.

8.     Change the threshold values to 70 for the green arrow and 30 for the yellow arrow. 

9.     Change the type to be Number instead of Percent.

10.    Click OK.

11.    Click Apply and then click OK

Icon sets are also available via the Quick Analysis icon  in Excel 2013 and 2016, although the icon selection is limited.

 Formatting cells that contain certain text

You can easily format all cells that contain certain text:

•    Select the cells that you want to apply the conditional formatting to.

•    Click on the Home tab

•    Click on the Conditional Formatting icon 

•    Choose New Rule

•    At the top of the pop-up window, choose Format only cells that contain

•    Change CellValue to be Specific Text

•    Type the text string that you want to check for (case does not matter)

•    Click on Format to choose how to format the cells if the condition is true

•    Click OK.

 Using your own rules

In addition to the predefined conditional formatting options, you can also set conditional formatting according to your own rules. Before we get started on this, let’s introduce the rules manager.

         Rules manager

The rules manager is a really simple way of being able to get a handle on all of the conditional formatting you have in a workbook. As your spreadsheets become more complex you’ll need to make sure you know where to quickly reference all of the formatting rules you have setup and what data they may be affecting.

To access the Rules Manager:

•    Click on the Home tab    

•    Click on the Conditional Formatting icon 

•    Click the Manage Rules… option from the drop down menu

 The rules manager allows you to

•    View all rules in your workbook, individual worksheets or even just the selected cells

•    Create new rules using the pre-existing templates or by using formulas and statements

•    Edit and delete any existing rules

•    Edit the cell range that the rule is being applied to

•    Change the order of the hierarchy

5.1.1 The rules hierarchy

There are some occasions where it is useful to run the rules in a particular order.

Be aware that rules are processed from the top downwards. This means that for each cell in your selected range the top rule will be run first and then the second one and so on…

What happens if a cell satisfies the criteria of more than one rule?

If two rules are true, only one can apply. The rule that is higher in the hierarchy always takes precedence.

If a cell meets the criteria of the top two rules in the screenshot above (one is trying to turn it red because it is a duplicate value and the other is trying to turn it green because it is above the average) then the rule that is higher in the order is the one that will be applied. Therefore our cell would turn red because that is the first rule in the hierarchy.


 Creating a new conditional formatting rule

•    Open the Rules Manager (Click on the Home tab, click on the Conditional

Formatting icon and click on Manage Rules…)

•    Click on the drop down in the Show Formatting Rules for: box and choose This Worksheet

•    Click on New Rule

•    Choose Use a formula to determine which cells to format

•    Type the condition formula in the box o Always start the formula with an = sign

o  The result of the formula must always be TRUE or FALSE

o  Build the formula for one cell – you can then apply the formula to other cells

o  Use $ signs to control how cell references behave when the formula is applied to other cells  o Don’t use arrow keys to move your cursor within the formula as this will change your cell references.

•    Click on Format to choose how to format the cells if the condition is true

•    Click OK.

You have defined your rule. Now you need to specify the cells to which that rule will apply.

•    In the rules manager, click on the  icon for that rule. 

•    Use your mouse to select the range of cells in your worksheet that you want to apply that conditional formatting rule to.

•    Excel will automatically complete the cell references for you. 

•    Click on  to expand the Rules Manager again.

•    Click Apply and then OK.

Exercise E.

Creating a Simple Rule

1.     Open up the file and click on the Simple Rule tab.

This spreadsheet shows the number of ghosts busted by each member of staff on our ghostbusting team. We are going to create a rule that highlights in red any months where our target has not been met.

Note that this rule could also be set up using predefined conditional formatting rules, but we’re using it as a simple example to explain how to set up your own rule.

2.     Click in cell E2.

3.     Open up the Conditional Formatting Rules Manager and show all rules for this worksheet.

4.     Click on New Rule and click to choose Use a formula to determine which cells to format

5.     When building the rule, we will build it for cell E2 as this is the first cell in the range of cells to which we will apply our conditional formatting rule.

6.     In the formula box type =E2<E13

This formula will check whether the number of ghosts in cell E2 is less than the target specified in call E13

7.     Click your mouse on the E13 cell reference in your formula and press the F4 key.

This will add dollar signs to the cell reference for the target number of ghosts busted. Without making this cell reference absolute using the dollar signs, when we apply the conditional formatting rule to other cells in the worksheet, this cell reference will be changed in relation to where the new cells are, which will affect the result of the formula.

For more information on Absolute Referencing, see the Exercise F which gives a refresher on absolute referencing.

8.     Click on the Format button, choose to fill the cells with red and click OK.

9.     Click OK.

10.    In the rules manager, click on the  icon for our new rule to specify the range of cells to which we want to apply this rule.

11.    On the worksheet itself, use your mouse to select the cell range E2 to G7. Then click  to expand the Rules Manager again.

12.    Click Apply then OK to apply the rule. 

Exercise F.

Relative, absolute and mixed referencing refresher

Confused about $ signs and cell referencing? These are key to using conditional formatting, so let’s remind ourselves how relative, mixed and absolute cell references work.

1.   Open up the file Absolute

2.   This file shows the prices for a list of products and the surcharges and discounts applied.

3.   Build a formula in cell C11 to calculate the surcharge for that row =B11*B5

4.   Use autofill to copy the formula down column C. There is a problem!

5.   Double click on cell C11. The boxes show the cell references. These are OK. 

6.   Press Esc and then double click on cell C12. The boxes show the cell references. These surcharge cell reference is incorrect. Instead of pointing to cell B5, the cell reference has changed to B6. This is because the cell reference is relative, Excel adds 1 to any row number in a formula when that formula is copied down a column.

7.   Press Esc and then double click on cell C13. The boxes show the cell references. The surcharge cell reference is incorrect. Instead of pointing to cell B5, the cell reference has changed to B7. This is because the cell reference is relative, Excel adds 1 to any row number in a formula when that formula is copied down a column.

This is what has happened to our formula as it was copied down column C:

Cell

Formula

C11 (original formula)

=B11*B5

C12

=B12*B6

C13

=B13*B7

We want the first cell reference to increment by 1 for each row, but we always want our formula to refer to cell B5 for the surcharge regardless of the current row. To do this, we must make the cell reference absolute.

8.   Press Esc and double click on cell C11.

9.   Click your insertion point so that it is flashing on the B5 cell reference in your formula.

10.  Press the F4 key. This will add $ signs to your cell reference so that your formula reads =B11*$B$5. This instructs Excel to anchor the B5 cell reference when the formula is copied to other cells, to not change the column letter or row number. The cell reference is absolute and the formula must always use cell B5.

11.  Press ENTER to save the formula.

Use autofill to copy the new formula down column C and double click to check the formula in cells C12 and C13 as before.

12.  This is what has happened to our formula as it was copied down column C. Unlike before, the B5 cell reference is copied correctly to the other cells as the $ signs have marked this reference as absolute.

Cell

Formula

C11 (original formula)

=B11*$B$5

C12

=B12*$B$5

C13

=B13*$B$5

In columns E to G in the worksheet, the volume discount that will be applied according to the number of items purchased: 5% will be discounted if 1-5 items are purchased: 12% will be discounted if 6-9 items are purchased; and there is a discount of 15% for buying more than 10..

The formula to calculate the final price will be: price including surcharge * volume discount.

Let’s build that formula in cell E: 13. Click in cell E11 and build the formula:

=D11*$E$9

Learning from the earlier part of this exercise we know we want to make the discount percentage, so we’ve put the dollar signs around the E9 cell reference.

14. Use autofill to copy the formula down the column and double click to check the cell references in the formula of some of the newly populated cells.

This has worked! 15. Now use autofill to copy the formula across columns F and G.

16.    Double click to check the cell references in the formula of some of the newly populated cells.

What has happened? Columns F and G are picking up the 5% discount from column E as we made our E9 cell reference absolute.

This is not correct. We actually needed to only fix the row number. This is called a mixed reference.

17.    Double click on our original formula in cell E11 again. Click on the E9 cell reference and press F4 again. Pressing F4 toggles through the $ sign combinations for our cell reference and will give us E$9.

This will anchor row 9 in our cell reference, but allow Excel to increment the column letter when the formula is copied to other columns.

18.    Use autofill to copy the new formula down column E. Double click to check the cell references in the formula of some of the newly populated cells. 

This works!

19.    Use autofill to copy the new formula across columns F and G. Double click to check the cell references in the formula of some of the newly populated cells.

The % discount is correct, but our first cell reference has moved across the columns so the formula is no longer calculating a percentage of the price including surcharge in column D. We need to change this cell reference in our original formula to be a mixed reference, anchoring the column.

20.    Double click on our original formula in cell E11 again. Click on the D11 cell reference and press F4 three times. Pressing F4 toggles through the $ sign combinations for our cell reference and will give us $D11.

This will anchor column D in our cell reference, but allow Excel to increment the row number when the formula is copied down a column.

21.    Use autofill to copy the new formula down column E. Double click to check the cell references in the formula of some of the newly populated cells.

This works!

22.    Use autofill to copy the new formula across columns F and G. Double click to check the cell references in the formula of some of the newly populated cells.

This works!

So the position of your dollar signs is crucial. You can:

•    Create an absolute reference by anchoring both column and row reference ($E$9)

•    Create a mixed reference to anchor just the row reference (e.g. E$9) or just the column reference (e.g. $E9)

•    Leave a cell reference as relative so that both the column and row reference update according to the formula’s position.

Exercise G.

Creating a rule using OR

1. Open up the file OR

This spreadsheet shows the grade for each of our students. We are going to create a rule that highlights in yellow where a student has attained grade A, B or C.

To do this, we will use the OR operator in our formula. This has the syntax:

=OR(first condition, second condition)

e.g. =OR(D2=”A”,D2=”B”,D2=”C”) will check if D2 contains A B or C.

2.     Click in cell D2 and create a new rule in the Rules Manager.

When building the rule, we will build it for cell D2 as this is the first cell in the range of cells to which we will apply our conditional formatting rule

3.     In the formula box type =OR(D2=”A”,D2=”B”,D2=”C”)

This formula will check whether the grade in cell D2 is A, B or C.

4.     Click on the Format button, choose to fill the cells with yellow and click OK.

5.     In the Rules Manager, apply the rule to cells D2 to D10.

6.     Click Apply then OK to apply the rule. 

Exercise H.

Colour coding entire rows

To colour code entire rows according to a condition, apply the conditional formatting rule to all of the columns.

Usually you will need the column letter in your cell references absolute using the $ signs to ensure that the condition still works correctly, e.g. $E2

Let’s see an example: 

1.     Continue with the file from the previous exercise.

2.     Click in cell D2 and open the Rules Manager.

3.     Click on the  icon for our rule to change the range of cells to which we want to apply this rule.

4.     On the worksheet itself, use your mouse to select the cell range A2 to D10. Then click  to expand the Rules Manager again.

5.     Click Apply then OK to apply the rule. 

Nothing has happened. Why?

This is because when the rule is applied to other columns in a sheet, any cell references that have not been made absolute are changed according to the cells relative position.

So cells in column A will be checking if column A= A, B or C, not the contents of column.

So what do we do? We make the column in our cell reference absolute.

6.     Open the rules manager and show the rules for the entire worksheet.

7.     Click on the rule and click on Edit rule.

8.     Add a $ sign before each column letter in your formula so that it reads =OR($D2="A",$D2="B",$D2="C")

This will fix the column reference in the conditional formatting rule so that, wherever you apply the rule, the rule will refer to that fixed column rather than updating the rule.

9.     Click Apply then OK to apply the rule. 

The rows should be colour coded as shown:

Exercise I. Creating a rule using AND

1. Go back to or reopen up the file and click on the AND operator worksheet tab.

In exercise 5 we used a similar spreadsheet to mark in red any months where the target number of ghosts busted was not reached.

The rule applied to everyone in the sheet, which we feel is a little unfair as Junior Ghostbusters are being compared directly against their more experienced Ghostbuster colleagues.

To address this, we are going to create a rule that colours cells in red if the person has the job title Ghostbuster and they have not reached the target number of ghosts busted.

To do this, we will use the AND operator in our formula. This has the syntax:

=AND(first condition, second condition,…)

e.g. =AND(D2=D11,E2<E11) checks if D2 matches as D11 and that E2 is less than E11). 2. Click in cell E2 and open up the Conditional Formatting Rules Manager and show all rules for this worksheet.

3.     Click on New Rule and click to choose Use a formula to determine which cells to format

4.     When building the rule, we will build it for cell E2 as this is the first cell in the range of cells to which we will apply our conditional formatting rule.

5.     In the formula box type =AND(D2=D11,E2<E11)

This formula will check whether the person has the job title Ghostbuster (D2=D11) and the number of ghosts in cell E2 is less than the target specified in call E11. 6.          Add a dollar sign in front of the D2 reference.

This will make the column in the cell reference absolute so that the formula always checks against column D when checking the job title of the person.

7.     Click your mouse on the D11 cell reference in your formula and press the F4 key.

This will add dollar signs to make the cell reference absolute so that the formula always checks against cell D11 when checking to see if the person has the job title Ghostbuster. Without making this cell reference absolute using the dollar signs, when we apply the conditional formatting rule to other cells in the worksheet, this cell reference will be changed in relation to where the new cells are, which will affect the result of the formula.

8.     Click your mouse on the E11 cell reference in your formula and press the F4 key. This will add dollar signs to make the cell reference absolute so that the formula always checks against cell E11 when checking for the target number of ghosts busted. 

9.     Your formula should now read: =AND($D2=$D$11,E2<$E$11)10. Click on the Format button, choose to fill the cells with red and click OK.

11.    Click OK.

12.    In the rules manager, click on the  icon for our new rule to specify the range of cells to which we want to apply this rule.

13.    On the worksheet itself, use your mouse to select the cell range E2 to G7. Then click  to expand the Rules Manager again.

14.    Click Apply then OK to apply the rule. 

15.    Create another rule to check whether the junior ghostbusters have met their target in cell E12.

          Dates

Dates can be used in conditional formatting. For example, you can highlight where a date has passed or when a deadline is near.

5.3.1 Date format in Excel sheets

To be able to use dates in your formulae, the date must be typed into the spreadsheet correctly in the first place. For instance, 31/12/13 is a format Excel will recognize as a date, whereas 31.12.13 is not. 

To avoid problems in your spreadsheets, we recommend that you always type your dates in dd/mm/yy format. You can always format the cells so that the date is displayed in a different format if you prefer, e.g. 31 December 2013.

You can also set data validation on cells to produce an error message when a date is typed incorrectly. To do this:

•    Select the cells you want to validate (e.g. a column)

•    On the Data tab click on Data Validation

•    In the Allow field, choose Date from the drop down

? Specify a date range for the validation

? Click OK

A message will appear if an incorrect date format is typed into a cell.

5.3.2 Using dates in a formula

As long as the date has been input in the correct way, you can use your date in your formula as you would any other cell. Excel holds the date as a number in the background.

If you would like to compare a date against today, you can use the TODAY function. To see how this function works:

? Type =TODAY() in any empty cell on your sheet and press ENTER This returns today’s date in the cell. Let’s see how we can use this in conditional formatting.

Exercise J.

Using dates in conditional formatting

1. Open up the file  

This spreadsheet shows the due date and status for some projects running in our department.

We are going to set conditional formatting to:

•    Mark the entire row in red for any projects where the due date has passed

•    Mark the entire row in yellow for any projects where the due date is in 2 weeks or less

2.    If you have downloaded the exercise file from our website, it will possibly be out of date. So this exercise will work, change the dates in column C so that: o C5 and C7 dates are in the past

o C4, C6, C8 and C9 are dates that are more than 2 weeks in the future o C2, C3 and C10 are dates within the next 2 weeks.

For example, the dates shown at the top of the page would work for 9th March 2016. 3.   Click in cell C2 and open up the Conditional Formatting Rules Manager and show all rules for this worksheet.

4.     Click on New Rule and click to choose Use a formula to determine which cells to format

5.     When building the rule, we will build it for cell C2 as this is the first cell in the range of cells to which we will apply our conditional formatting rule.

6.     Type the formula =$C2<TODAY()

This will check whether the due date in column C is in the past (less than today’s date).

7.     Click on the Format button, choose to fill the cells with red and click OK.

8.     Click OK.

9.     In the rules manager, click on the  icon for our new rule to specify the range of cells to which we want to apply this rule.

10.    On the worksheet itself, use your mouse to select the cell range A2 to D10. Then click  to expand the Rules Manager again.

11.    Click Apply then OK to apply the rule. 

All of the rows with a date in the past are marked in red. Let’s mark the rows for any projects nearing the deadline.

12.    Click on cell C2 and open up the Conditional Formatting Rules Manager and show all rules for this worksheet.

13.    Click on New Rule and click to choose Use a formula to determine which cells to format

14.    When building the rule, we will again build it for cell C2 as this is the first cell in the range of cells to which we will apply our conditional formatting rule.

15.    Type the formula =$C2<=(TODAY()+14) This will check whether the due date in column C is in 2 weeks or less (less than or equal to today + 14 days)

16.    Click on the Format button, choose to fill the cells with yellow and click OK.

17.    Click OK.

18.    In the rules manager, click on the  icon for our new rule to specify the range of cells to which we want to apply this rule.

19.    On the worksheet itself, use your mouse to select the cell range A2 to D10. Then click  to expand the Rules Manager again.

20.    Click Apply then OK to apply the rule.

Exercise K.

Changing the rules hierarchy

None of our rows are red now. Why? If we open up our rules manager, we can see that our red rule for projects with a completion date in the past is still there. So why hasn’t it been applied?

For rows with a date in the past, both our rules are true. The date IS less than 2 weeks from today AND is in the past.

However, if two rules exist, only one can apply. The rule that is higher in the hierarchy in the rules manager always takes precedence.

To control the order of rules in the hierarchy, use the  buttons to move rules up and down the list.

21.    Move the yellow rule down so that it appears below the red row in the rules hierarchy.

22.    Click on Apply and click OK.

23.    Add another rule to the top of the list to turn rows green if the status is Completed in column D.

 Comparing with cells on another sheet using VLOOKUP

You can use VLOOKUP within your conditional formatting formulae, to compare a value against a value on a different sheet.

Exercise L.

Comparing data on other sheets using VLOOKUP

Note: this exercise assumes an understanding of the VLOOKUP function.

1.     Open up the file  

2.     This workbook lists the number of hits each course we run received on our website in 2012 and 2013.

Column C on the 2013 worksheet contains a VLOOKUP formula to check whether the course existed in 2012.

Double click on cell C2 and then click on the  icon on the formula bar to see how VLOOKUP formulae are built. This formula checks:

•    If cell A2 exists in the data table with the range A2 to B43 on the 2012 sheet

•    if it exists, the contents of column 2 will be returned

•    the formula will check for exact matches only.

Let’s try building a VLOOKUP into a conditional formatting rule. We’ll colour all cells in column D on the 2013 sheet where value is larger than the number of hits for that course in column C on the 2012 sheet.

3.     Click in cell D2 and open up the Conditional Formatting Rules Manager and show all rules for this worksheet.

4.     Click on New Rule and click to choose Use a formula to determine which cells to format

5.     When building the rule, we will build it for cell D2 as this is the first cell in the range of cells to which we will apply our conditional formatting rule.

6.     Type the formula

=D2>VLOOKUP(A2,'2012'!$A$2:$C$43,3,FALSE)

This checks whether the number in D2 is greater than the corresponding figure for that course code on the 2012 worksheet.

7.     Click on the Format button, choose to fill the cells with green and click OK.

8.     Click OK.

9.     In the rules manager, click on the  icon for our new rule to specify the range of cells to which we want to apply this rule.

10.    On the worksheet itself, use your mouse to select the cell range D2 to D28. Then click  to expand the Rules Manager again.

11.    Click Apply then OK to apply the rule.

5.4.1 Note for using conditional formatting on cells containing formulae You cannot check for #N/A within a cell when using conditional formatting. 

i.e. In the previous exercise, you could not set up a conditional formatting rule in column C on the 2013 sheet to colour any cells containing #N/A. 

To do this, you would need to use the IFERROR() function along with your VLOOKUP to return some text instead of #N/A if the result is an error. e.g. the formula in cell C2 would read: 

=IFERROR(VLOOKUP(A2,'2012'!$A$2:$B$43,2,FALSE),"-")

 to show – instead of #N/A in any cells where there is an error as the result of the formula.

 Filtering using conditional formatting

Once conditional formatting is applied to a column, the formatting will be available for you to filter the column according to format.

Exercise M.

Filtering

1.     Open the file

2.     Click in column D.

3.     On the Home tab, click on the Sort and Filter icon. 

4.     Click on Filter.

5.     Click on the drop down arrow in cell A1 to choose the filter.

6.     Point at Filter by color and click to choose green.

7.     The sheet will be filtered to only show rows where column D is green.

Decouvrir ces documents

  • EXCEL course learning outcomes

    EXCEL course learning outcomes

  • MS EXCEL advanced tutorial

    MS EXCEL advanced tutorial

  • EXCEL tutorial questions and answers

    EXCEL tutorial questions and answers

  • EXCEL tutorial nested IF function

    EXCEL tutorial nested IF function

  • Learn VBA programming with MS EXCEL

    Learn VBA programming with MS EXCEL

  • Learn EXCEL from beginner to advanced

    Learn EXCEL from beginner to advanced

  • EXCEL tutorial SUMIFS function

    EXCEL tutorial SUMIFS function

  • EXCEL tutorial Math functions

    EXCEL tutorial Math functions

Articles connexes

  • Excel Tutorial : How to count and add cells by color
  • Excel tutorial: How to use search and replace functions
  • Tutorial : How to convert Excel tables to HTML
  • Excel tutorial: Insert and delete page breaks in a spreadsheet
  • Tutoriel Excel : fonctions avancées
  • Les Meilleurs livres pour Apprendre Ms Excel 2019 ou 365
  • Meilleures formations MS Excel vidéo en ligne
  • Excel : supprimer une feuille, cellule, un tableau, caractère
  • Contactez-nous
  • A propos de nous
  • On recrute
  • Rechercher dans le site
  • Politique de confidentialité
  • Droit d'auteur/Copyright
  • Conditions générales d'utilisation
  • Plan du site
  • Accueil
  • Blog
  • Finance et compta.
  • Formations Pro.
  • Logiciels & Apps
  • Organisation
  • Cours informatique
  • Aide à la rédaction
  • Etudes et Metiers
  • Science et Tech
  • Titans de la Tech
id 11354 02