8 If then else

If...Then...Else
Ribbon groups used
The Font group and the Clipboard group on
the Home ribbon.
You will be creating a worksheet for a shop that sells mirrors.
It offers cut-to-size mirrors and they need a worksheet that
will provide instant quotes to customers.
Details
• The shop offers only one thickness of glass, 6mm.
It offers a choice of polished, or polished and
bevelled edges.
• The price of the mirror is dependent upon the
surface area and the perimeter length.
• These are the prices:
– £32 per square metre of surface area
– £1.70 per linear metre of perimeter for polished edges
– £2.10 per linear metre of perimeter for polished and
bevelled edges
Changing font and size
• Select cell A1
• Change the font size to 26 by clicking the
down arrow on the right-hand side of the Font
Size list box in the Font group on the Home
ribbon.
• Change the font – choose the one you like
from the Font list box.
• Make the text in cell A1 bold.
• Move the contents of cell B1 to D1.
• Change some more of the headings and formats to
look like this:
Tip: To copy formatting from a cell or cell range, select the cell(s) containing the
formatting you want to copy. Click the Format Painter button in the Clipboard
group on the Home ribbon. Click the cell(s) you want to format. All the original
cell’s formatting is copied.
Adding the formulae
• The calculation for Total surface area is Width x
Height. What will the formula be?
• Type the formula =B9*B10 in cell B12.
• The calculation for Total perimeter length is 2 x (Width
+ Height). What will the formula be?
• Type the formula =2*(B9+B10) in cell B13.
• The calculation for Price for surface area is Total
surface area (square metres) x Price per square
metre. What will the formula be?
• Type the formula =B12*B4 in cell D12.
• Save your changes.
• Try out the formulae by typing the length and width of
a mirror in cells B9 and B10, respectively.
If statements
• Type the letter P or PB into cell D9 to specify the
mirror’s edges.
• The calculation for the Price for edges has to
include an IF statement because it is conditional
on whether they are polished, or polished and
bevelled.
– IF the edges are polished THEN the price for the edges
= perimeter length x polished price
– IF the edges are bevelled THEN the price for the edges
= perimeter length x bevelled price
...breaking it down further.
• IF cell D9 = P THEN cell D13 = B13*B5
• IF cell D9 = PB THEN cell D13 = B13*B6
• Select cell D13. Click on the Insert Function to
the left of the formula bar.
• The Insert Function dialogue box is displayed.
Select IF from the Select a function: list. If you
cannot see it in the list, change the category
to Logical. Click OK.
• The Function Arguments dialogue box is
displayed. Complete the three IF fields as
shown:
• Click OK
• Fill in the last formula for the total price, next to
the Instant Quote heading in cell B15. It should
be =SUM(D12:D13)
• Test your spreadsheet by typing 0.5 in cell B9 and
1.2 in cell B10. The Instant Quote should be
24.98
Formulae so far
• Now you are going to apply a 10% discount if
the quote is £100 or more.
• Type and format the cells A16 and A17,
changing the border around the quote as
shown:
• You will use the IF statement as before, but
this time you need the formula to recognise
when the price quoted in cell B15 is more
than £99.99.
• To do this you will use the > operator.
• The calculation for the Discount is conditional
on whether the quoted price is more than
£99.99.
• IF the instant quote is more than £99.99 THEN
the discount = instant quote x 10%,
OTHERWISE the discount = 0.
• Breaking it down further:
• IF cell B15 > 99.99 THEN B16 = B15*10% OTHERWISE
cell B16 = B15*0
• Click cell B16 and open the Function Arguments
dialogue box as before.
• Complete the three IF fields using the > operator.
• Type the formula =B15-B16 in cell B17 to
calculate the final price.
• Test your spreadsheet model by typing in
different widths and lengths, and different
types of mirror into the worksheet to see the
effect on the final price.
• Finally, format all the currency cells to show
pound signs, set to two decimal places.
• Does the worksheet work properly?
Your spreadsheet should look like this:
Adding some colour
• The quote worksheet might look better if it
was a bit more colourful. You can do this by
changing the font colour and the background
fill colour.
Changing the font colour:
• Select cell A1.
• Click the down-arrow on the Font Colour
button in the Font group on the Home ribbon
and select a colour.
Changing the background fill colour:
• With cell A1 still selected, click the downarrow on the Fill Color button in the Font
group on the Home ribbon, select a colour.
Aligning cell content
• You can set where the text appears in a cell – left,
right, top, bottom or centre. Use the Align Right,
Align Left and Centre buttons and the Top,
Middle and Bottom buttons in the Alignment
group on the Home ribbon.
• You can also use the Format Cells dialogue box,
which allows more options (e.g. slanting).
• Widen row 1 by clicking and dragging between
the row selectors of row 1 and row 2.
• Select cells A1 and D1 and click the Middle Align
button.
Cell content orientation
• Right-click cell A1 and select Format Cells… from
the shortcut menu.
• Select the Alignment tab on the Format Cell
dialogue box.
• Change the orientation of the text by
dragging the red dot on the Orientation
dial so that the text is slightly slanting.
• Click OK.
Add some more colours, trying different formatting
so that it looks something like this:
Save the changes.
Exercise 6
• Try to work independently.
• Follow all the instructions closely.
• When complete, print your work in normal
view and formula view making sure that the
print fits on one page and shows the gridlines
and row and column headings.
Name:
Date:
Progress checklist 8
• Do I know the difference between relative and absolute cell
referencing?
• Do I know how to insert absolute addressing into a spreadsheet
cell?
• Can I calculate a percentage using a spreadsheet?
• Can I format cells to currency?
• Do I know how to merge and centre cells?
• Do I know how to apply wrapping to cell content?
• Can I add borders to cells?
• Can I find a replace text?
• Can I add headers and footers?
• Can I insert fields into headers and footers?