Cell Formats and Styles in Microsoft Excel 2003

Cell Formats and Styles in Microsoft Excel 2003
Introduction
In the same way that a paragraph or piece of text uses a format to specify
its appearance in Microsoft Word, a format can be applied to a cell or its
contents in Microsoft Excel. Not only are there the usual font, font
size/colour, bold/italic/underline and justification settings found in Word but
also less commonly-used aspects such as background colour, borders and
text orientation. In addition Excel allows you to format a number (eg how
many decimal places) or date/time (eg to display the month as August or
Aug or /08/). By applying a format you do not alter the contents of the cell in
any way - just how it is displayed.
Where a particular cell format is to be used on a regular basis, it can be
stored as a style - just like the styles in Word such as Heading 1 or Normal.
Excel already has a few built-in styles, such as Percent and Currency but
you can also define your own.
Formatting a Cell
You should be familiar with the formatting buttons on the left of the lower
(Formatting) toolbar - ie [Font], [Font Size], [Bold], [Italic], [Underline], [Align
Left], [Center] and [Align Right]. The next button, [Merge and Center], is
only found in Excel and will be discussed later. The next five buttons are
specifically for formatting numbers. Finally, on the right of the toolbar, there
are buttons for [Borders], [Fill Color] and [Font Color].
Formatting Text
Text can be formatted in Excel in much the same way as in Word:
1. Start with a new workbook (click on the [New] button) or move to an
empty worksheet
2. Type Formatting Text in cell A1 then press <Ctrl Enter> to enter the
text and remain in A1
3. Try out the [Font], [Font Size], [Bold], [Italic] and [Underline] buttons
You'll find they act just as they do in Microsoft Word but on the whole
contents of the cell. To apply a format to just part of the text:
4. Drag through the word(s) to be formatted on the Formula Bar - eg
select the word Text
5. Click on the required format button
6. Press <Enter> to see the result and move to cell A2
You can also apply the required formatting as you type the text:
7. In A2 type Circumference=2 then click on the [Font] list arrow and
choose Symbol
8. Type the letter p then click on the [Font] list arrow again and choose
Arial (note that π only shows as such in the cell, not on the Formula
Bar)
9. End by typing the letter r then press <Enter>
Tip: When entering text into a cell, use <Ctrl b>, <Ctrl i> etc to apply
bold/italic/etc as you type.
For super/sub-script:
11. In cell A3 type Area= then change the [Font] to Symbol, type a p and
change the [Font] back to Arial and type r
12. Next, open the Format menu and choose Cells...
13. Under Effects turn on Superscript - press <Enter> for [OK]
14. Type 2 then press <Enter> to finish typing
Note that certain characters can also be typed in by using <Alt> and the
Numeric Keypad - superscript 2 is <Alt 0178>, for example.
Tips: Another way to get text with special characters into Excel is to type it
in Word then Copy and Paste it across. You can also make use of
AutoCorrect (in the Tools menu) to set up abbreviations for text - any
entries made here are available throughout Microsoft Office.
Formatting Numbers
As well as the normal formatting available for text, Excel provides special
formatting for numbers. Whenever such data is typed into a cell, Excel
automatically tries to give it an appropriate format. It's important to
understand these formats and to know how to clear or change them, if
necessary.
1. Move down to cell A5
2. Type Formatting Numbers in the cell then press <Enter> to move to
A6
3. Type the number 1234.56 then press <Ctrl Enter> to remain in A6
4. Click on the [Currency] style button in the centre of the lower toolbar a pound sign and comma (thousands) separator appears
5. Now try out the next four buttons - [Percent Style], [Comma Style],
[Increase Decimal] and [Decrease Decimal] (on the University PCs
there's also a [Euro] style)
6. Click on [Decrease Decimal] again and note how the display is
rounded to the number of decimal places
7. Click on the style buttons at random and note how freely you can
change the display format
To clear a format:
8. Open the Edit menu and choose Clear then Formats
It is all too easy to impose a format on a cell by accident:
1. Press <Enter> to move to cell A7
2. Type £5 into the cell then then press <Ctrl Enter> to remain in A7
3. Try typing other numbers into cell A7 - they will all be shown as a
currency, even though you aren't typing the pound sign
Formats may also be copied to other cells in calculations:
4. Move to cell A8
5. Type in the formula =a7/10 and press <Ctrl Enter>
Again, the answer is shown as pounds.
Automatic formatting can give very peculiar results - you need to
understand what's happening:
6. Use <up arrow> to move back to cell A7
7. Type 5-2 and press <Ctrl Enter>
Excel interprets this as a date (5th February in the current year) - you forgot
the equals sign if you wanted to calculate 5 minus 2. Dates are stored as
numbers (in fact the number of days since the start of the year 1900). In cell
A8 this value has been divided by 10, but the cell has retained its original
format - hence the result of £3875.30 (in 2006). Now, whenever you try to
type a number into cell A7 you will find it will be converted into a date. To
see this:
8. Still in cell A7, type in a number - press <Enter>
To clear the unwanted formats from both the cells:
9. Hold down <Shift> and press <up arrow> to select cells A7 and A8
10. Open the Edit menu and choose Clear then Formats
Note: as an alternative to Clear, you could have imposed one of the built-in
styles on the cells - eg the [Comma Style]. These override any other
formats set.
Tip: Another way to clear an unwanted format is to use format painting move to a cell which hasn't been formatted, click on the [Format Painter]
button then on the cell with the rogue format
Numeric Text
One numeric format which Excel doesn't allow is leading zeros. This makes
it difficult, for example, to store telephone numbers with their full dialling
codes. The answer is to store the number as numeric text. To do this, you
either fix the cell format to text (see later) or precede the number with a
single quote:
1. Move down to cell A9
2. Type in a single quote (the key between the <L> and <Enter>) then a
telephone number, including the dialling code
3. Press <Enter> and you will find the leading zero is displayed (but the
quote disappears)
4. Try applying a numeric style (eg [Currency]) - you will find the display
doesn't change
Because the number is stored as text, numeric styles do not apply. If you
were to type in a number without the leading single quote, then they would.
Using a single quote to insert text in this way is useful for other characters
too. For example:
•
showing equations with a leading equals sign
•
•
•
showing numeric text which include dashes and/or slashes (otherwise
interpreted as dates)
showing a leading plus sign
where you have a numeric heading (eg year date) which mustn't be
included in calculations
This last example can be very important. Try summing up the values in cells
A6 to A9:
5.
6.
7.
8.
Move down to cell A10
Click on the [AutoSum] button on the Standard Toolbar
Press <Enter> to accept the range A6:A9
Note that the answer doesn't include the telephone number!
Formatting Cells
So far you have seen how the contents of a cell can be formatted. In this
next section you will format the cell itself. The toolbar buttons provided let
you set the justification, fill and font colour and cell border. You will explore
further formatting options in the section following this one.
1. Press <Ctrl Home> to move to cell A1
2. Click on the list arrow attached to the [Font Color] button and select a
different colour
3. Next, click on the list arrow attached to the [Fill Color] button and
select a different colour
Note how only cell A1 is coloured - you are formatting just this cell, even
though the contents may spill into cells to the right. You will see what to do
about this later.
4. Click on the list arrow attached to the [Borders] button and select a
[Thick Box Border] - the bottom right option (note the other options
available)
Again, note how the border isn't drawn on the right. This is because it would
interfere with the text spilling into B1. To cure this and the fill colour you
need to merge the cells:
5. Drag through cells A1 and B1 to select them then click on the [Merge
and Center] button (to the left of [Currency])
6. Finally, point the mouse cursor to the border between columns
headings B and C, hold down the mouse and widen the column to 150
pixels
[Merge and Center] is more frequently used to centre headings across sets
of data - eg to place a year date over 12 columns showing the months. If
you don't want the heading centred, simply rejustify it:
7. Click on the [Align Left] button
One disadvantage of merged cells is that some of the usual Excel
commands no longer work properly. Here are a few examples:
8. Try double clicking on the column heading border between A and B - it
doesn't size to fit properly, width has to be set manually
9. Select column A by clicking on the column heading letter and then
[Cut] it - an error message appears
10. Try [Copy] instead then click in cell E1 and press <Enter> for [Paste] the merged cell isn't copied
11. Select column A again and change the [Fill Color], choosing a
different one from cell A1 - only cells A2 onwards are coloured
12. Open the Edit menu, choose Clear then Formats - the error message
again appears, use [Undo] to remove the fill colour
To remove the merging:
13. Click on cell A1 then on the [Merge and Center] button again - cell B1
reappears
Advanced Formatting
So far you have used the toolbar buttons to set the cell format. In this next
section you will use the Format ... Cells command.
1. Move to cell A11 then open the Format menu and choose Cells...
The following Format Cells dialog box is displayed:
The Number Tab
1. Click on the Number tab
On the Number tab you can specify how you would like the contents of the
cell to appear. Here, there are many more built-in formats for you to use.
General gives no specific format and can be used to clear other formats.
Note also the Text format - click on it and read what it says. Under Special
there's even a Phone Number format. Take care when you use this as the
information is stored as a real number and would, for example, be added
into a summed range. You will be looking at Custom formats later.
2. Click on the Special Category and choose Phone Number then press
<Enter> for [OK]
3. Type in your phone number (no spaces) then press <Enter> to move
to cell A12 - the leading zero disappears, instead the dialling code is
enclosed in brackets
The Alignment Tab
1. In cell A12, open the Format menu and again choose Cells...
2. Click on the Alignment tab
Here, under Text Alignment you have the usual Horizontal: alignment (of
left, centre, right etc) but also Vertical: alignment (of top, centre or bottom).
You can also Indent: the cell contents, if you need to. Under Orientation
you can set the cell contents to read at any angle or vertically down. Finally,
under Text control you can Wrap text (text wraps round onto several lines
within the column width - the row height increases) or Shrink to fit (the font
size changes with the column width).
3. Under Text alignment change Vertical: to Center and Indent to 1
4. Under Text control turn on Shrink to fit then press <Enter> for [OK]
5. Type Shrinking text into cell A12 then click on the [Enter] button on
the Formula Bar
6. Increase the height of row 12 by moving the mouse to the border
between the row numbers 12 and 13 (a double-headed arrow appears)
and dragging the border down (set the height to roughly 80 pixels) - the
text is centred vertically
7. Now decrease the width of column A by doing the same on the border
between the column headings A and B (set the width to approx 60
pixels) - the font size becomes very small
Text orientation and Wrap text were discussed in the Intermediate training
notes. If you don't know about them, look at the section entitled Text
Rotation and Wrapping.
The Font Tab
1. Open the Format menu and choose Cells... again
2. Click on the Font tab
Most of the settings here are available from the toolbar buttons. The only
additional features are Underline, where you can set double or special
accounting underlining, and Effects such as Strikethrough or
Super/Subscript (as you saw earlier).
The Border Tab
1. Click on the Border tab
Though the borders themselves can all be set via the toolbar button, here
you can set a special border line Style: and/or Color:. You need to select
these before you set the border. You could even have different
colours/styles for each border!
2. Click on the list arrow attached to Color and choose a border colour
3. Select a border Style from the selection provided
4. Choose which Border you want showing - or use [Outline] under
Preview
5. Press <Enter> for [OK] to see the effect
Note: If you want to apply a border to a range of cells, select the cells
before drawing the border.
The Patterns Tab
1. Open the Format menu and choose Cells... again
2. Click on the Patterns tab
Here you have the normal range of Fill Colours, but you can also set a
pattern:
3. Click on the list arrow attached to the Pattern button and choose a
pattern from those provided at the top of the box
4. If you want a coloured pattern, click on the list arrow again and choose
a colour
5. If you want a coloured background, choose a colour from those
provided
6. Press <Enter> for [OK] to see the effect
The Protection Tab
1. Open the Format menu and choose Cells... again
2. Click on the Protection tab
If you read the help provided on this tab you will discover that the options
are ineffective unless the whole worksheet is protected. To find out more
about this, see the document entitled Setting Security in Microsoft Excel
2003.
3. Press <Esc> (or click on [Cancel]) to close the Format Cells dialog
box
Built-in Styles and the Style Toolbar Button
You have already used the style buttons ([Currency], [Percent] etc) but
you can also set a style using the [Style] button. Whereas this button is
prominently displayed in Microsoft Word (the first on the toolbar), it is
completely absent in Excel. To turn it on:
1. Click on the [More Buttons] down-arrow on the far right of the
Formatting Toolbar
2. Move the mouse over Add or Remove Buttons then choose
Customize...
3. Under Categories: on the Commands tab choose Format
4. Drag the [Style:] button (plus drop-down list arrow) up to the
Formatting Toolbar - you can choose where to place it ... to match
Word, put it on the far left
5. Press <Esc> or <Enter> to [Close] the Customize dialog box
6. Move to cell A6
7. Click on the list arrow attached to the new [Style] button and choose
Currency [0]
This gives you a currency format with 0 decimal places - the toolbar button
gave you 2 (this format is available from the drop-down style list as
Currency). In the sections which follow you will create your own styles,
which will be added to the style list.
Customising a Cell Format
Excel lets you create custom styles through the Format ... Cells command:
1. Open the Format menu and choose Cells...
2. Click on the Number tab
You can see here that cell A6 currently has an Accounting format with 0
decimal places and a pound sign. To set up a Euro format:
3. Click on the list arrow attached to Symbol, scroll down the list and
choose € Euro (€123)
4. Increase the number of Decimal places: to 2
5. Press <Enter> for [OK] to format the number and widen the column, if
necessary
Excel also allows you to create much more complicated formats, if you
need to. Here, let's create a format which displays €1234.56 cents.
6. Open the Format menu and choose Cells...
7. On the Number tab set the Category: to Custom
Under the heading Type: is the code used to create the format. It's very
complicated and not that easy to understand. The first few characters
define the Euro symbol, then the #,##0.00 signifies the data to be used for
the number (0 is a character which must be displayed; # denotes an
optional character). This pattern is repeated several times to cover what
happens with negative numbers (eg are they shown in red), each pattern
being separated by a semi-colon.
8. Click on the code immediately before the first semi-colon - you can use
the <arrow keys> to move the insertion point to the exact position
9. Now type "cents" note that the double quotes are needed to insert
text
10. Press <Enter> for [OK] to format the number
You should now have both the Euro sign and cents added to the display.
Note that you didn't change the settings for negative numbers, however. If
you were to type a negative value into the cell, the word cents would not be
shown. You can add this to your format code, if you like.
Creating a Style
Creating a style works just the same as it does in Microsoft Word. You
select the specially formatted cell then define a new style name:
1. Make sure you are in cell A6 (with the euros and cents)
2. Click on the (white) [Style] box - do not use the list arrow
3. Type the name for the new style - eg Euro - and press <Enter>
You now have you own Euro style. To apply it to a different cell:
4. Move down to cell A7
5. Click on the list arrow attached to the [Style] button and choose Euro your style will be applied to the data
Modifying a Style
To modify a style:
1. Open the Format menu and choose Style... - the following dialog box
appears
Down the left hand side of the dialog box you can specify which
components make up the style (these correspond to the Format Cells tabs,
explored earlier). On the right you can [Modify...] the current style,
[Merge...] (copy) styles between open workbooks or [Delete] a style. You
can also create a new style, based on an existing one, using [Add]. To do
this you must first give the new style a name:
2.
3.
4.
5.
6.
7.
Click in the Style name: box and modify the name to Euro [0]
Now click on the [Modify...] button
On the Number tab, set Decimal places to 0
Press <Enter> or click on [OK]
Click on [Add] to create the new modified style
Finally, press <Enter> for [OK] to close the dialog box
Try out your new style, if you like. Note that the word cents will not appear
as you don't have any decimal places showing (even if you use the
[Increase Decimal] button to display some).
Conditional Formatting
One very useful formatting option available in Excel is to be able to choose
different formats depending on the contents of the cell. In this next exercise
you will be using the example file used in the Intermediate course:
1. Click on the [Open] button, or use Open... from the File menu
2. Change the default directory by clicking on the list arrow attached to
the Look In: box - choose User (D:) then [Open] the folder called
Training
3. Click on phoenix.xls then press <Enter> for [Open]
The exercise is to colour the cells in column F according to the Colour
specified in each cell.
4. Click on cell F2
5. Open the Format menu and choose Conditional Formatting... - the
following dialog box appears:
Note that you are currently looking at Condition 1. You can set up several
alternatives as you will see:
6. Using the list arrows etc, set the condition to read Cell Value Is equal
to Red-Brown
7. Now click on the [Format...] button
8. Click on the Patterns tab and choose a red-brown colour
9. Press <Enter> or click on [OK]
10. Now click on the [Add >>] button to get Condition 2
11. Using the list arrows etc, set the condition to read Cell Value Is equal
to Blue-Green
12. Repeat steps 7 to 9, this time choosing a blue-green colour from the
palette provided
13. Click on [OK] to set up the conditional formatting
Finally, you need to copy the conditional format to the other cells in the
column:
14. Click on the [Format Painter] toolbar button
15. Click on the column heading letter F to paint the format to the whole
column