IT2000:FIGURES USING =IF FORMULAE
A common task you might want to do is get your computer to take some data you’ve entered, get some corresponding information and use that for a calculation or another display.

A simple example would be to check whether a price was OK or expensive.

In plain English:

if the price is greater than 15.99, it’s expensive, otherwise it’s OK.

This can be written as a formula in an Excel spreadsheet and it follows the structure of the sentence above:

=IF(price>15.99,"it's expensive","OK")

The structure is this:

=IF All formulae start with =
( Next you need to open a bracket
Price Then the cell to check (here I’ve named the cell – see other notes – but it could be an ordinary cell reference like C4)
> How is the value compared?
15.99 What’s it compared to?
, Then a comma
“it’s expensive” Then type the message if the comparison is true – in inverted commas
, Another comma
“OK” Type the message if it’s not true – in inverted commas
) Close the bracket

IF expressions can be really useful and can get very long and complicated if you want.

Here’s the IF expression which will give different grades, depending on marks in an exam.

If Mark is
The Grade is
Greater than 89
A
From 80 to 89
B
From 70 to 79
C
From 60 to 69
D
Less than 60
E

The IF expression is:

=IF(Mark>89,"A",IF(Mark>79,"B",IF(Mark>69,"C",IF(Mark>59,"D","E"))))

This is called a nested IF formula. Note that you just need one = at the start, to open a bracket after each IF and then to close them all at the end. Looks odd but it works.

 

© Andrew Hill, Milton Keynes, UK MMVI