Formatting Cells and Ranges

In Excel, you can format cells in a wide variety of ways—everything from choosing how to display the borders and background to controlling how Excel represents the text you enter in the cell. This section shows you how the most useful kinds of formatting work and how to apply them.

Each cell comes with basic formatting applied to it—the font and font size to use and usually the General number format, which you'll meet shortly. So when you create a new workbook and start entering data in it, Excel displays the data in a normal-size font.

TIP: To control the font and font size Excel uses for new workbooks, choose Excel images Preferences or press Cmd+, (Cmd and the comma key). Click the General icon in the Authoring area of the Excel Preferences dialog box to display the General pane. Open the Standard font menu and click the font you want; the Body Font choice at the top of the list gives you the body font set in the workbook's template; if you change this font, you change the font used in all the styles except the Title style (which uses the Heading font). Then choose the size in the Size pop-up menu. Click the OK button to close the Excel Preferences dialog box.

Understanding the Three Main Tools for Applying Formatting

Excel gives you three main tools for applying formatting to cells and ranges:

  • Formatting Toolbar. If you display this toolbar (choose View images Toolbars images Formatting from the menu bar), you can quickly apply some of the most widely used formatting. Figure 4–5 shows the Formatting toolbar (displayed undocked so you can see it more easily) with its controls labeled.

NOTE: The Home tab of the Ribbon also provides the formatting commands you find on the Formatting toolbar, so you can use whichever is more convenient.

images

Figure 4–5. The Formatting toolbar is often the easiest way to apply widely used formatting.

  • Home tab of the Ribbon. The Font group provides widely used font formatting; the Alignment group offers horizontal and vertical alignment, orientation, indentation, wrapping, and merging; and the Number group gives you a quick way to apply essential number formatting. Figure 4–6 shows the Font group with its controls labeled. Figure 4–7 shows the Alignment group and Number group with their controls labeled.
images

Figure 4–6. You can quickly apply essential font formatting, borders, and fills from the Font group on the Home tab of the Ribbon.

NOTE: The Increase Font Size button, Decrease Font Size button, and Borders pop-up menu appear in the Font group on the Home tab of the Ribbon only when the Excel window is wide enough to accommodate them.

images

Figure 4–7. From the Alignment group on the Home tab of the Ribbon, you can set horizontal and vertical alignment, orientation, and wrapping. From the Number group, you can apply number formatting.

  • Format Cells dialog box. When you need to apply formatting types that don't appear on the Standard toolbar or on the Home tab of the Ribbon, open the Format Cells dialog box and work on its six tabs, which you'll meet later in this chapter. The easiest way to display the Format Cells dialog box is to Ctrl+click or right-click a cell or a selection and then click Format Cells on the context menu. You can also open the Format Cells dialog box by pressing Cmd+1 or choosing Format images Cells from the menu bar.

Controlling How Data Appears by Applying Number Formatting

When you enter a number in a cell, Excel displays it according to the number formatting applied to that cell. For example, if you enter 39250 in a cell formatted with General formatting, Excel displays it as 39250. If the cell has Currency formatting, Excel displays a value such as $39,250.00 (depending on the details of the format). And if the cell has Date formatting, Excel displays a date such as 18 June 2011 (again, depending on the details of the format). In each case, the number stored in the cell remains the same—so if you change the cell's formatting to a different type, the way that Excel displays the data changes to match.

Table 4–1 explains Excel's number formats and tells you the keyboard shortcuts for applying them. You can also apply number formatting by using the buttons on the Standard toolbar, the Number Format pop-up menu and buttons in the Number group of the Home tab of the Ribbon, and the Number tab of the Format Cells dialog box (see Figure 4–8).

images

Figure 4–8. Use the Number tab of the Format Cells dialog box when you need access to the full range of number formatting.

Table 4–1. Excel's Number Formats

Number
Format
Explanation Examples Keyboard
Shortcut
General Excel's default format for all cells in new worksheets.
No specific format, but displays up to 11 digits per cell and uses no thousands separator. For any entry longer than 11 digits, General format uses scientific notation (see the “Scientific” entry later in this table).
1234567
Industry
Ctrl+Shift+~ (tilde)
Number Displays the number of decimal places you choose. You can choose whether to use the thousands separator and how to display negative numbers. 1000
1,000
1,000.00
Ctrl+Shift+!
Currency Displays the number of decimal places you choose, using the thousands separator. You can choose which currency symbol to display (for example, $) and how to display negative numbers. $2,345.67
–$2,345.67
Ctrl+Shift+$
Accounting Displays the number of decimal places you choose, using the thousands separator. You can choose which currency symbol to use. The symbol appears aligned at the left edge of the cell. Negative numbers appear with parentheses around them. $  1,000,000
$  (99.999.00)
Date Displays any of a variety of date formats. 6/24/2011
Thursday, June
24, 2011
Ctrl+Shift+#
Time Displays any of a variety of time formats. 11:59:59 PM
23:59:59
Ctrl+Shift+@
Percentage Displays a percent sign and the number of decimal places you choose. 78.79%
200%
Ctrl+Shift+%
Fraction Displays the number as a fraction. Fractions tend to be visually confusing, so use them only if you must—for example, for betting charts. 1/2
1 1/4
Scientific Displays the number in exponential form, with E and the power to which to raise the number. You can choose how many decimal places to use. 1.2346E+08
–9.8765E+07
Ctrl+Shift+^
Text Displays and treats the data as text, even when it appears to be another type of data (for example, a number or date). Product List 18
Special Displays the data in the format you choose: Zip Code, Zip Code + 4, Phone Number, or Social Security Number. 10013
10013-8295
(212) 555-9753
722-86-8261
Custom Displays the data in the custom format you choose. Excel provides dozens of custom formats, but you can also create your own formats. [Various]

UNDERSTANDING HOW EXCEL STORES DATES AND TIMES

To create a custom number format of your own, follow these steps:

  1. Select a cell that contains the right kind of data. For example, if you want to create a custom date format, select a cell with Date formatting and a date entered in it.
  2. Open the Format Cells dialog box by pressing Cmd+1.
  3. Click the Number tab if it's not displayed at first.
  4. In the Category list box, click the Custom item. Excel displays the controls for creating a custom format (see Figure 4–9). Your sample data appears in the Sample box at the top.
    images

    Figure 4–9. You can create custom number formats by typing them in the Type text box on the Number tab of the Format Cells dialog box. Click the most similar format in the list box to give yourself a head start.

  5. Scroll down the list box until you find the format that's closest to the format you want to create, then click that format. Excel adds the codes for the format to the Type text box and shows the sample data in that format.
  6. Edit the format so that the sample data appears the way you want it (see the instructions after this list).
  7. Click the OK button to close the Format Cells dialog box.

To create a custom format, you enter format codes telling Excel how to display the information. A custom format can contain a single format, like the date format shown in Figure 4–9, but you can include up to four different formats, separated by semicolons:

  • First format. How to display positive numbers.
  • Second format. How to display negative numbers.
  • Third format. How to display zero values.
  • Fourth format. How to display text.

Table 4–2 explains the codes for creating custom number formats.

Table 4–2. Codes for Creating Custom Number Formats

Code Effect Example
[color name] Display the color named. Put the appropriate color in brackets as the first item in the section: [Black], [Red], [Blue], [Green], [White], [Cyan], [Magenta], or [Yellow]. For example, #,##0_);[Red](#,##0) displays negative numbers in red.
Number Format Codes
# Display a significant digit. ###.# displays three significant digits before the decimal point and one significant digit after it. (A significant digit is a nonzero figure.)
0 Display a zero if no digit would otherwise appear in this place. 000 displays a three-digit number, padding it out with leading zeros if necessary. For example, if you enter 7, Excel displays 007.
% Display a percentage. #% displays the number multiplied by 100 and with a percent sign. For example, 8 appears as 800%.
? Display as a fraction. # ???/??? displays a number and three-digit fractions—for example, 9 107/112.
. Display a decimal point. ###.## displays three significant digits before the decimal point and two significant digits after it.
, Two meanings: display the thousands separator or scale the number down by 1,000. Thousands separator: $#,###,### displays the dollar sign, seven significant digits, and the thousands separator.
Scale by 1,000: €#.##,,, " million" displays the euro symbol, one significant digit before the decimal point and two after, the number scaled down by a million, and the word million (after a space). For example, if you enter 12345689, Excel displays €1.23 million.
Date and Time Format Codes
d Display the day in numeric format. d-mmm-yyyy displays 6/1/11 as 1-Jun-2011.
dd Display the day in numeric format with a leading zero for single-digit days. dd/mmm/yy displays 6/1/11 as 01/Jun/11. Leading zeroes can be helpful for standardizing on two-digit dates and for aligning date entries.
ddd Display the day as a three-letter abbreviation. ddd dd/mm/yyyy displays 6/1/11 as Wed 01/06/2011.
dddd Display the day in full. dddd, dd/mm/yyyy displays 6/1/11 as Wednesday, 01/06/2011./
m Display the month in numeric format. d/m/yy displays 6/1/11 as 6/1/11.
mm Display the month in numeric format with a leading zero. mm/dd/yy displays 6/1/11 as 06/01/11.
mmm Display the month as a three-letter abbreviation. dd-mmm-yy displays 6/1/11 as 01-Jun-2011.
mmmm Display the month in full. dd mmmm, yyyy displays 6/1/11 as 01 June, 2011.
mmmmm Display the month as a one-letter abbreviation. January, June, and July appear as J; April and August appear as A; and so on. This code works when you're short of space and include all the months in sequence; if you use only some months, it's confusing.
yy Display the year as a two-digit number. m/d/yy displays 6/1/11 as 6/1/11.
yyyy Display the year in full. dd-mmm-yyyy displays 6/1/11 as 01-Jun-2011.
h Display the hour. h:m displays 2:22 as 2:22.
hh Display the hour with a leading zero. hh:mm displays 2:22 as 02:22.
m Display the minute. h:m displays 2:01 as 2:1.
mm Display the minute with a leading zero. hh:mm displays 2:22 as 02:22. To distinguish mm from the months code (also mm), use it immediately after hh or immediately before ss.
s Display the second. h:m:s displays 2:22:01 as 2:22:1.
ss Display the second with a leading zero. hh:mm:ss displays 2:22:01 as 02:22:01.
.0, .00, .000 Display tenths, hundredths, or thousandths of seconds. h:mm:ss.000 displays 2:22:01.11 as 2:22:01.110.
A/P Display A for A.M. and P for P.M. h:mm A/P displays 2:22 as 2:22 A. You can use uppercase A/P or lowercase a/p to specify which case to display.
AM/PM Display AM for A.M. and PM for P.M. h:mm am/pm displays 14:22 as 2:22 PM. Excel uses uppercase regardless of which case you use.
[] Display the elapsed time in the specified unit. [h]:mm:ss displays the elapsed time in hours, minutes, and seconds—for example, 55:38:43.
Text Format Codes
_ Display a space as wide as the specified character. _) makes Excel enter a space the width of a closing parenthesis. You'd use this to align positive numbers with negative numbers that appear in parentheses.
* Repeat the specified character to fill the cell. *0 makes Excel fill the cell with 0 (zero) characters. This format is specialized, but you may need it to draw the viewer's attention to particular cells.
Display the following character. [Blue]$#,###.00 *;[Green]$#,###.00 D displays positive numbers in blue and followed by an asterisk, and negative numbers in green and followed by a D.
“string” Display the string of text. $#,##0.00" Net" displays the word Net after the entry. Note the leading space between the " and the word.
@ Concatenate the specified string with the user's text input. "Value: "@ enters Value: and a space before the user's text input. You can use this only in the fourth section (the text section) of a custom format.
N/A Display the specified character. $ - + = / ( ) { } : ! ^ & ‘ ' ~ <> [SPACE]

Setting the Workbook's Overall Look by Applying a Theme

To control the overall look of a workbook, apply a suitable theme to it by choosing Home imagesThemes imagesThemes and then clicking the theme you want on the Themes panel.

The theme applies a set of colors and a pair of fonts to the workbook. After applying the theme, you can change the colors or fonts by using the Colors pop-up menu or the Fonts pop-up menu in the Themes group on the Home tab of the Ribbon.

Choosing How to Align Cell Contents

You can quickly align the contents of cells by using the buttons in the Alignment group on the Home tab of the Ribbon or the controls on the Alignment tab of the Format Cells dialog box (see Figure 4–10):

  • Horizontal alignment. You can align the text Left, Center, Right, or Justify; apply General alignment, which depends on the data type (left for text, right for numbers); choose Center Across Selection to center the text across multiple cells; or choose Distributed (Indent) to distribute the text across the cell (using wider spaces between words).

NOTE: The Fill horizontal alignment fills the cell with the character you specify.

images

Figure 4–10. The Alignment tab of the Format Cells dialog box lets you rotate text to precise angles when needed.

  • Vertical alignment. You can align text Top, Center, Bottom, or Justify. You can also choose Distributed to distribute the text vertically, which can be useful when you rotate the text so that it runs vertically.
  • Rotate text. Use the Orientation box on the Alignment tab of the Format Cells dialog box or the Orientation pop-up menu in the Alignment group.
  • Indentation. You can indent the text as far as is needed.
  • Wrap. You can wrap the text to make a long entry appear on several lines in a cell rather than disappear where the next cell's contents start. When you wrap text, Excel automatically increases the row height to accommodate the wrapped text. (If you set a specific row height that's less than the height needed to display all the wrapped text, only the text that fits appears in the cell.)
  • Shrink to fit. Select this check box on the Alignment tab of the Format Cells dialog box to shrink the text so that it fits in the cell. Shrinking works well when the text is only a bit too big for the cell. If the text is much too big, shrinking makes it too small to read.
  • Merge cells. Use the Merge & Center pop-up menu in the Alignment group to merge selected cells together into a single cell. You can also center an entry across a merged cell. In the Format Cells dialog box, you can merge cells by selecting the Merge cells check box on the Alignment tab.

Choosing Font Formatting

You can quickly format the contents of a cell (or the selected part of a cell's contents) by using the controls on the Standard toolbar, the controls in the Font group on the Home tab, or the Font tab of the Format Cells dialog box (see Figure 4–11).

images

Figure 4–11. Use the Font tab of the Format Cells dialog box when you need a fuller range of font formatting than the Standard toolbar and the Ribbon's Font group provide.

Applying Borders and Fills

To apply borders to a cell, open the Borders pop-up menu in the Font group on the Home tab of the Ribbon, and then click the border type you want (see Figure 4–12).

images

Figure 4–12. You can quickly apply borders from the Borders pop-up menu in the Font group of the Home tab.

TIP: If you have displayed the Formatting toolbar, you can apply a border by clicking its Borders pop-up button and then clicking the border type on the panel. After choosing a border type this way, you can apply it quickly to another cell by clicking the main part of the Borders button rather than the pop-up button. You can also tear off the Borders palette to keep it visible so that you don't have to keep opening it. Click the Borders pop-up button, then click the double line at the top of the palette and drag it off the toolbar. When you have finished using the torn-off palette, close it by clicking the Close button at the left end of its title bar.

For more border options, click the Border Options item at the bottom of the Borders pop-up menu to display the Border tab of the Format Cells dialog box (see Figure 4–13). You can also choose Format images Cells from the menu bar (or press Cmd+1) and then click the Border tab. Use the controls on the Border tab to set up the borders you want. For example, to apply a heavy bottom border, click a dark line in the Style box, and then click the Bottom Border button in the Border box. Then click the OK button.

images

Figure 4–13. Use the Border tab of the Format Cells dialog box when you need to change the line style or color of borders.

To apply a fill, use the Fill Colors pop-up menu in the Font group on the Home tab of the Ribbon or the Fill Colors pop-up menu on the Formatting toolbar, or work on the Fill tab of the Format Cells dialog box.

Applying Protection to Cells

The Protection tab of the Format Cells dialog box contains only two controls:

  • Locked. Select this check box to lock a cell against changes.
  • Hidden. Select this check box to hide the formula in a cell (the formula's result remains visible).

After selecting either of these check boxes, you must protect the worksheet before the locking or hiding takes effect. You'll learn how to protect a worksheet in the section “Protecting a Worksheet or Workbook” in Chapter 13.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.144.38.253