Skip to main content

Conditional Formatting in Excel

  - If statements in spreadsheets can be very long and complicated. Consider this problem. You have a spreadsheet of student exam marks. Suppose you want to add the grades as well. If the student scored above 80 it's an A; if the student scored between 60 and 79, it's a B; if the student scored between 45 and 59, it's a C; if the student scored between 30 and 44, it's a D; and if the student scored less than 30, it's Fail. The question is, what does your IF statement look like?
Well, it might look like this:
=IF(B2>=80, "A", IF(B2>=60, "B", IF(B2>=45, "C", IF(B2 >=30, "D", "Fail"))))
What the IF statement is doing is nesting another IF statement on the False condition. So it says, "If B2 is greater than or equal to 80 THEN put an A in cell B15; if it's not, execute another IF statement."
But don't worry if that long IF statement is making your brain hurt - it is quite complicated!
However, we'll use that long IF statement to explore Conditional Formatting. You'll be glad to know that there is a spreadsheet already prepared for you, for this lesson. So right click the link below and save the spreadsheet to your own computer.
Open up the spreadsheet you've just downloaded, and take a look at it. It should be this one:
The Averages Spreadsheet
It looks a bit hard to follow at the moment. It's difficult to know what the data is supposed to represent. Conditional formatting will help to clarify things.

 

Conditional Formatting

We can use Conditional logic, however, to format the spreadsheet. What we'll do is to colour those Overall Averages depending on the grade. One colour will represent a high grade, a second colour will mean an average grade, and a third colour will mean a low grade. So let's get started.
  • With your Spreadsheet open, Highlight the cells with Overall Averages in them (From B12 to I12)
  • With the cells highlighted, click on Format form the menu bar
  • From the drop down menu, click on Conditional Formatting
  • A dialogue box appears, the one below:
At the top, it says Condition 1, and there are 4 text boxes to fill in. The first two "Cell Value Is" and "Between" will suit our purposes, so:
  • Click inside the third text box and enter 80
  • Click inside the fourth text box and enter 100
  • You should have "Cell Value Is between 80 and 100"
You can now set the colour to use for this condition. So click the Format button. Another dialogue box appears. From the Patterns Tab Strip, select a colour or pattern to use. Then click the OK button at the bottom. Your dialogue box will look something like the one below:
You can now add a second condition. To do that, click the Add button at the bottom of the dialogue box. Condition 2 will appear. Repeat the above process: enter some numbers for the middle set of grade (65 to 79, perhaps), and select a different colour by clicking the Formatbutton. Add a third condition for the lowest grades. When you're done, click the OK button. Your Overall Averages should change colour depending on what grade the student got. (Unfortunately, Excel only allows you a maximum of 3 conditions.)
Your spreadsheet might look something like the one in the next image:

The conditional formatting allows you to see at a glance which students are doing well, and which are doing badly. Poor Mark!

Exercise

Format the Student Grades so that your spreadsheet looks like the one below (you can use different colours, if you like).


In the spreadsheet above, you can now see more easily who's doing well and who isn't. In the next section, we'll take a look at CountIF. Again, we'll use the student spreadsheet.

Comments

Popular posts from this blog

Beginners PHP  -This is a complete and free PHP programming course for beginners. It's assumed that you already have some HTML skills. But you don't need to be a guru, by any means. If you need a refresher on HTML, then click the link for the Web Design course on the left of this page. Everything you need to get started with this PHP course is set out in section one below. Good luck! Home Page > PHP Section One - An Introduction to PHP 1. What is PHP and Why do I need it? 2. What you need to get started 3. Installing and testing Wampserver 4. Troubleshooting > PHP Two - Getting Started With Variables 1. What is a Variable? 2. Putting text into variables 3. Variables - some practice 4. More variable practice 5. Joining direct text and variable data 6. Adding up in PHP 7. Subtraction 8. Multiplication 9. Division 10. Floating point numbers > PHP Three - Conditional Logic 1. If Statements 2. Using If Statements 3....
Visual Basic .NET Contents Page   -This computer course is an introduction to Visual Basic.NET programming for beginners. This course assumes that you have no programming experience whatsoever. It's a lot easier than you think, and can be a very rewarding hobby! You don't need to buy any software for this course! You can use the new FREE Visual Basic Express Edition from Microsoft. To see which version you need, click below: Getting the free Visual Studio Express - Which version do I need? > VB .NET One - Getting Started   1. Getting started with VB.NET 2. Visual Basic .NET Forms 3. Adding Controls using the Toolbox Home Page 4. Adding a Textbox to the Form 5. Visual Basic .NET and Properties 6. The Text Property 7. Adding a splash of colour 8. Saving your work 9. Create a New Project >   VB .NET Two - Write your first .NET code   1. What is a Variable? 2. Add a coding button to the Form 3. Writing y...
The Excel SumIF Function  - Another useful Excel function is SumIF. This function is like CountIf, except it adds one more argument: SUMIF( range ,  criteria ,  sum_range ) Range and criteria are the same as with  CountIF  - the range of cells to search, and what you want Excel to look for. The Sum_Range is like range, but it searches a new range of cells. To clarify all that, here's what we'll use SumIF for. (Start a new spreadsheet for this.) Five people have ordered goods from us. Some have paid us, but some haven't. The five people are Elisa, Kelly, Steven, Euan, and Holly. We'll use SumIF to calculate how much in total has been paid to us, and how much is still owed. So in Column A, enter the names: In Column B enter how much each person owes: In Column C, enter TRUE or FALSE values. TRUE means they have paid up, and FALSE means they haven't: Add two more labels: Total Paid, and Still Owed. Your spreadsheet should look something li...