Tải bản đầy đủ (.pdf) (124 trang)

Wiley Office 2007 Bible phần 4 doc

Bạn đang xem bản rút gọn của tài liệu. Xem và tải ngay bản đầy đủ của tài liệu tại đây (5.47 MB, 124 trang )

FIGURE 14-18
Excel offers several pasting options.
Using the Paste Special Dialog box
For maximum flexibility in what gets pasted, choose Home ➪ Clipboard ➪ Paste (bottom half of button)➪Paste
Special to display the Paste Special dialog box (see Figure 14-19). You also can right-click and select Paste
Special to display this dialog box. This dialog box has several options, which I explain in the following list.
Excel actually has several different Paste Special dialog boxes. The one displayed depends on
what’s copied. This section describes the Paste Special dialog box that appears when a range or
cell has been copied.
FIGURE 14-19
The Paste Special dialog box.
NOTE
NOTE
329
Essential Worksheet and Cell Range Operations
14
20 046913 ch14.qxp 5/2/07 9:07 PM Page 329
For the Paste Special command to be available, you need to copy a cell or range. (Choosing
Home ➪ Clipboard ➪ Cut doesn’t work.)
n
All: Pastes the cell’s contents, formats, and data validation from the Windows Clipboard.
n
Formulas: Pastes values and formulas, with no formatting.
n
Values: Pastes values and the results of formulas (no formatting). The destination for the copy can
be a new range or the original range. In the latter case, Excel replaces the original formulas with
their current values.
n
Formats: Copies only the formatting.
n
Comments: Copies only the cell comments from a cell or range. This option doesn’t copy cell


contents or formatting.
n
Validation: Copies the validation criteria so the same data validation will apply. Data validation is
applied by choosing Data ➪ Data Tools ➪ Data Validation.
n
All Using Source Theme: Pastes everything, but uses the formatting from the document theme
of the source. This option is relevant only if you’re pasting information from a different work-
book, and the workbook uses a different document theme than the active workbook.
n
All Except Borders: Pastes everything except borders that appear in the source range.
n
Column Widths: Pastes only column width information.
n
Formulas And Number Formats: Pastes all values, formulas and number formats (but no other
formatting).
n
Values And Number Formats: Pastes all values and numeric formats, but not the formulas
themselves.
In addition, the Paste Special dialog box enables you to perform other operations, described in the follow-
ing sections.
Performing mathematical operations without formulas
The option buttons in the Operation section of the Paste Special dialog box let you perform an arithmetic
operation. For example, you can copy a range to another range and select the Multiply operation. Excel
multiplies the corresponding values in the source range and the destination range and replaces the destina-
tion range with the new values.
This feature also works with a single copied cell, pasted to a range. Assume that you have a range of values,
and you want to increase each value by 5 percent. Enter 105% into any blank cell and copy that cell to the
Clipboard. Then select the range of values and bring up the Paste Special dialog box. Select the Multiply
option, and each value in the range is multiplied by 105 percent.
If the destination range contains formulas, the formulas are also modified. In many cases, this

is
not
what you want.
Skipping blanks when pasting
The Skip Blanks option in the Paste Special dialog box prevents Excel from overwriting cell contents in your
paste area with blank cells from the copied range. This option is useful if you’re copying a range to another
area but don’t want the blank cells in the copied range to overwrite existing data.
WARNING
WARNING
TIP
TIP
330
Making the Numbers Work with Excel
Part III
20 046913 ch14.qxp 5/2/07 9:07 PM Page 330
Transposing a range
The Transpose option in the Paste Special dialog box changes the orientation of the copied range. Rows
become columns, and columns become rows. Any formulas in the copied range are adjusted so that they
work properly when transposed. Note that you can use this check box with the other options in the Paste
Special dialog box. Figure 14-20 shows an example of a horizontal range (A1:F1) that was transposed to a
vertical range (A3:A8).
FIGURE 14-20
Transposing a range changes the orientation as the information is pasted into the worksheet.
If you click the Paste Link button in the Paste Special dialog box, you create formulas that link
to the source range. As a result, the destination range automatically reflects changes in the
source range.
Using Names to Work with Ranges
Dealing with cryptic cell and range addresses can sometimes be confusing. (This confusion becomes even
more apparent when you deal with formulas, which I cover in Chapter 15.) Fortunately, Excel allows you to
assign descriptive names to cells and ranges. For example, you can give a cell a name such as Interest_

Rate,
or you can name a range JulySales. Working with these names (rather than cell or range addresses) has sev-
eral advantages:
n
A meaningful range name (such as Total_Income) is much easier to remember than a cell address
(such as AC21).
n
Entering a name is less error-prone than entering a cell or range address.
n
You can quickly move to areas of your worksheet either by using the Name box, located at the left
side of the Formula bar (click the arrow to drop down a list of defined names) or by choosing
Home ➪ Editing ➪ Find & Select ➪ Go To (or F5) and specifying the range name.
n
Creating formulas is easier. You can paste a cell or range name into a formula by using Formula
Autocomplete, a new feature in Excel 2007.
n
Names make your formulas more understandable and easier to use. A formula such as =Income —
Taxes is more intuitive than =D20 — D40.
TIP
TIP
331
Essential Worksheet and Cell Range Operations
14
20 046913 ch14.qxp 5/2/07 9:07 PM Page 331
Creating range names in your workbooks
Excel provides several different methods that you can use to create range names. Before you begin, however,
you should be aware of some important rules about what is acceptable:
n
Names can’t contain any spaces. You may want to use an underscore character to simulate a space
(such as Annual_Total).

n
You can use any combination of letters and numbers, but the name must begin with a letter. A
name can’t begin with a number (such as 3rdQuarter) or look like a cell reference (such as
QTR3). If these are desirable names, you can precede the name with underscore: _3rd Quarter
and _QTR3.
n
Symbols, except for underscores and periods, aren’t allowed.
n
Names are limited to 255 characters, but it’s a good practice to keep names as short as possible yet
still meaningful and understandable.
Excel also uses a few names internally for its own use. Although you can create names that override Excel’s
internal names, you should avoid doing so. To be on the safe side, avoid using the following for names:
Print_Area, Print_Titles, Consolidate_Area, and Sheet_Title.
Using the New Name dialog box
To create a range name, start by selecting the cell or range that you want to name. Then, choose Formulas ➪
Defined Names ➪ Define Name. Excel displays the New Name dialog box, shown in Figure 14-21. Note
that this is a resizable dialog box. Drag a border to change the dimensions.
FIGURE 14-21
Create names for cells or ranges by using the New Name dialog box.
Type a name in the box labeled Name (or use the name that Excel proposes, if any). The selected cell or
range address appears in the box labeled Refers To. Use the Scope drop-down to indicate the scope for the
name. The scope indicates where the name will be valid, and it’s either the entire workbook, or a particular
sheet. If you like, you can add a comment that describes the named range or cell. Click OK to add the name
to your workbook and close the dialog box.
Using the Name box
A faster way to create a name is to use the Name box (to the left of the Formula bar). Select the cell or range
to name, click the Name box, and type the name. Press Enter to create the name. (You must press Enter to
actually record the name; if you type a name and then click in the worksheet, Excel doesn’t create the
name.) If a name already exists, you can’t use the Name box to change the range to which that name refers.
Attempting to do so simply selects the range.

332
Making the Numbers Work with Excel
Part III
20 046913 ch14.qxp 5/2/07 9:07 PM Page 332
The Name box is a drop-down list and shows all names in the workbook. To choose a named cell or range,
click the Name box and choose the name. The name appears in the Name box, and Excel selects the named
cell or range in the worksheet.
Using the Create Names From Selection dialog box
You may have a worksheet that contains text that you want to use for names for adjacent cells or ranges. For
example, you may want to use the text in column A to create names for the corresponding values in column
B. Excel makes this task easy to do.
To create names by using adjacent text, start by selecting the name text and the cells that you want to name.
(These items can be individual cells or ranges of cells.) The names must be adjacent to the cells that you’re
naming. (A multiple selection is allowed.) Then, choose Formulas ➪ Defined Names ➪ Create From
Selection. Excel displays the Create Names From Selection dialog box, shown in Figure 14-22. The check
marks in this dialog box are based on Excel’s analysis of the selected range. For example, if Excel finds text
in the first row of the selection, it proposes that you create names based on the top row. If Excel didn’t guess
correctly, you can change the check boxes. Click OK, and Excel creates the names.
FIGURE 14-22
Use the Create Names From Selection dialog box to name cells using labels that appear in the worksheet.
If the text contained in a cell would result in an invalid name, Excel modifies the name to
make it valid. For example, if a cell contains the text Net Income (which is invalid for a name
because it contains a space), Excel converts the space to an underscore character. If Excel encounters a
value or a numeric formula where text should be, however, it doesn’t convert it to a valid name. It simply
doesn’t create a name — and does not inform you of that fact.
If the upper-left cell of the selection contains text and you choose the Top Row and Left
Column options, Excel uses that text for the name of the entire data excluding the top row and
left column. So, before you accept the names that Excel creates, take a minute to make sure that they refer
to the correct ranges. If Excel creates a name that is incorrect, you can delete or modify it by using the
Name Manager (described next).

Managing names
A workbook can have any number of names. If you have many names, you should know about the Name
Manager, shown in Figure 14-23.
CAUTION
CAUTION
NOTE
NOTE
333
Essential Worksheet and Cell Range Operations
14
20 046913 ch14.qxp 5/2/07 9:07 PM Page 333
FIGURE 14-23
The Name Manager is new in Excel 2007.
The Name Manager is a new feature in Excel 2007.
The Name Manager appears when you choose Formulas ➪ Defined Names ➪ Name Manager (or press
Ctrl+F3). The Name Manager has the following features:
n
Displays information about each name in the workbook. You can resize the Name Manager
dialog box and widen the columns to show more information. You can also click a column head-
ing to sort the information by the column.
n
Allows you to filter the displayed names. Clicking the Filter button lets you show only those
names that meet a certain criteria. For example, you can view only the worksheet level names.
n
Provides quick access to the New Name dialog box. Click the New button to create a new
name without closing the Name Manager.
n
Lets you edit names. To edit a name, select it in the list and then click the Edit button. You can
change the name or the Refers To range or edit the comment.
n

Lets you quickly delete unneeded names. To delete a name, select it in the list and click Delete.
Be extra careful when deleting names. If the name is used in a formula, deleting the name
causes the formula to become invalid. (It displays
#NAME?.) However, deleting a name can be
undone, so if you find that formulas return
#NAME? after you delete a name, choose Undo from the Quick
Access Toolbar (or press Ctrl+Z) to get the name back.
If you delete the rows or columns that contain named cells or ranges, the names contain an invalid refer-
ence. For example, if cell A1 on Sheet1 is named Interest and you delete row 1 or column A, the name
Interest then refers to
=Sheet1!#REF! (that is, to an erroneous reference). If you use Interest in a for-
mula, the formula displays
#REF.
The Name Manager is useful, but it has a shortcoming: It doesn’t let you display the list of
names in a worksheet range so you can view or print them. Such a feat is possible, but you
need to look beyond the Name Manager.
TIP
TIP
CAUTION
CAUTION
NEW FEATURE
NEW FEATURE
334
Making the Numbers Work with Excel
Part III
20 046913 ch14.qxp 5/2/07 9:07 PM Page 334
To create a list of names in a worksheet, first move the cell pointer to an empty area of your worksheet —
the list is created at the active cell position and overwrites any information at that location. Press F3 to dis-
play the Paste Name dialog box, which lists all the defined names. Then click the Paste List button. Excel cre-
ates a list of all names in the workbook and their corresponding addresses.

Adding Comments to Cells
Documentation that explains certain elements in the worksheet can often be helpful. One way to document
your work is to add comments to cells. This feature is useful when you need to describe a particular value
or explain how a formula works.
To add a comment to a cell, select the cell and then choose Review ➪ Comments ➪ New Comment.
Alternatively, you can right-click the cell and choose Insert Comment from the shortcut menu. Excel inserts
a comment that points to the active cell. Initially, the comment consists of your name. Enter the text for the
cell comment and then click anywhere in the worksheet to hide the comment. You can change the size of
the comment by clicking and dragging any of its borders. Figure 14-24 shows a cell with a comment.
FIGURE 14-24
You can add comments to cells to help clarify important items in your worksheets.
Cells that have a comment display a small red triangle in the upper-right corner. When you move the
mouse pointer over a cell that contains a comment, the comment becomes visible.
You can control how comments are displayed. Access the Advanced tab of the Excel Options dia-
log box. In the Display section, an option lets you turn off the comment indicators if you like.
Formatting comments
If you don’t like the default look of cell comments, select the comment text and use the Home ➪ Font and
Home ➪ Alignment groups to make changes to the comment’s appearance.
For even more formatting options, right-click the comment’s border and choose Format Comment from the
shortcut menu. Excel responds by displaying the Format Comment dialog box, which allows you to change
many aspects of its appearance.
You also can display an image inside of a comment. Select the Colors and Lines tab in the
Format Comment dialog box. Click the Color drop-down list in the Fill section and select Fill
Effects. In the Fill Effects dialog box, click the Picture tab and then click the Select Picture Button to specify
a graphics file. Figure 14-25 shows a comment that contains a picture.
TIP
TIP
TIP
TIP
335

Essential Worksheet and Cell Range Operations
14
20 046913 ch14.qxp 5/2/07 9:07 PM Page 335
FIGURE 14-25
This comment contains a graphic image.
Reading comments
To read all of the comments in a workbook, choose Review ➪ Comments ➪ Next. Click this command
repeatedly to cycle through all the comments in a workbook. Choose Review ➪ Comments ➪ Previous to
view the comments in reverse order.
Hiding and showing comments
If you want all cell comments to be visible (regardless of the location of the cell pointer), choose Review ➪
Comments ➪ Show All Comments. This command is a toggle; select it again to hide all cell comments. To
toggle the display of an individual comments, select its cell and then choose Review ➪ Comments ➪
Show/Hide Comment.
Editing comments
To edit a comment, activate the cell, right-click, and then choose Edit Comment from the shortcut menu.
When you’ve made your changes, click any cell.
Deleting comments
To delete a cell comment, activate the cell that contains the comment and then choose Review ➪ Comments ➪
Delete. Or, right-click and then choose Delete Comment from the shortcut menu.
Summary
This chapter taught essential skills dealing with worksheets, cells, and ranges. Among the wide variety of
skills covered, you learned to create, copy, move, rename, and change the view of worksheets. You also
learned to work with rows and columns within sheets, performing actions including resizing, inserting, and
deleting rows and columns. The chapter moved on to teach you about cells and ranges, covering how to
make various kinds of selections, to naming ranges and adding comments to cells. The next chapter moves
on to covering formulas and functions to perform calculations.
336
Making the Numbers Work with Excel
Part III

20 046913 ch14.qxp 5/2/07 9:07 PM Page 336
F
ormulas are what make a spreadsheet program so powerful. If it weren’t for
formulas, a spreadsheet would simply be a glorified word-processing docu-
ment that has great support for tabular information. You use formulas in
your Excel worksheets to calculate results from the data stored in the worksheet.
When data changes, those formulas calculate updated results with no extra effort
on your part. This chapter introduces formulas and functions and helps you get
up to speed with this important element.
Understanding Formula Basics
A formula is entered into a cell. It performs a calculation of some type and
returns a result, which is displayed in the cell. Formulas use a variety of opera-
tors and worksheet functions to work with values and text. The values and text
used in formulas can be located in other cells, which makes changing data easy
and gives worksheets their dynamic nature. For example, you can see multiple
scenarios quickly by changing the data in a worksheet and letting your formulas
do the work.
A formula can consist of any of these elements:
n
Mathematical operators, such as
+ (for addition) and * (for multiplication)
n
Cell references (including named cells and ranges)
n
Values or text
n
Worksheet functions (such as SUM or AVERAGE)
When you’re working with a table, a new feature in Excel 2007
enables you to create formulas that use column names from
the table — which can make your formulas much easier to read. I discuss table

formulas later in this chapter. (See the section “Using Formulas in Tables.”)
NEW FEATURE
NEW FEATURE
337
IN THIS CHAPTER
Understanding formula basics
Entering formulas and functions
into your worksheets
Understanding how to use
references in formulas
Correcting common formula
errors
Tips for working with formulas
Introducing Formulas
and Functions
21 046913 ch15.qxp 5/2/07 9:07 PM Page 337
After you enter a formula, the cell displays the calculated result of the formula. The formula itself appears in
the Formula bar when you select the cell, however.
Following are a few examples of formulas:
=150*.05 Multiplies 150 times 0.05. This formula uses only values and isn’t all that useful because it
always returns the same result. You may as well just enter the value 7.5 into the cell.
=A1+A2 Adds the values in cells A1 and A2.
=Income–Expenses Subtracts the value in the cell named Expenses from the value in the cell named Income.
=SUM(A1:A12) Adds the values in the range A1:A12.
=A1=C12 Compares cell A1 with cell C12. If they are identical, the formula returns TRUE; otherwise it
returns FALSE.
Formulas always begin with the equal sign so that Excel can distinguish them from text.
Using operators in formulas
Excel lets you use a variety of operators in your formulas. Operators are symbols that indicate the type of math-
ematical operation you want the formula to perform. Table 15-1 lists the operators that Excel recognizes. In

addition to these, Excel has many built-in functions that enable you to perform additional calculations.
TABLE 15-1
Operators Used in Formulas
Operator Name
+ Addition
- Subtraction
* Multiplication
/ Division
^ Exponentiation
& Concatenation
= Logical comparison (equal to)
> Logical comparison (greater than)
< Logical comparison (less than)
>= Logical comparison (greater than or equal to)
<= Logical comparison (less than or equal to)
<> Logical comparison (not equal to)
You can, of course, use as many operators as you need to perform the desired calculation.
NOTE
NOTE
338
Making the Numbers Work with Excel
Part III
21 046913 ch15.qxp 5/2/07 9:07 PM Page 338
Following are some examples of formulas that use various operators.
Formula What It Does
=”Part-”&”23A” Joins (concatenates) the two text strings to produce Part-23A.
=A1&A2 Concatenates the contents of cell A1 with cell A2. Concatenation works with values as
well as text. If cell A1 contains 123 and cell A2 contains 456, this formula would return
the value 123456.
=6^3 Raises 6 to the third power (216).

=216^(1/3) Returns the cube root of 216 (6).
=A1<A2 Returns TRUE if the value in cell A1 is less than the value in cell A2. Otherwise, it returns
FALSE. Logical-comparison operators also work with text. If A1 contained Bill and A2
contained Julia, the formula would return TRUE, because Bill comes before Julia
in alphabetical order.
=A1<=A2 Returns TRUE if the value in cell A1 is less than or equal to the value in cell A2.
Otherwise, it returns FALSE.
=A1<>A2 Returns TRUE if the value in cell A1 isn’t equal to the value in cell A2. Otherwise, it
returns FALSE.
Understanding operator precedence in formulas
When Excel calculates the value of a formula, it uses certain rules to determine the order in which the vari-
ous parts of the formula are calculated. You need to understand these rules if you want your formulas to
produce the desired results.
Table 15-2 lists the Excel operator precedence. This table shows that exponentiation has the highest prece-
dence (it’s performed first) and logical comparisons have the lowest precedence (they’re performed last).
TABLE 15-2
Operator Precedence in Excel Formulas
Symbol Operator Precedence
^ Exponentiation 1
* Multiplication 2
/ Division 2
+ Addition 3
– Subtraction 3
& Concatenation 4
= Equal to 5
< Less than 5
> Greater than 5
339
Introducing Formulas and Functions
15

21 046913 ch15.qxp 5/2/07 9:07 PM Page 339
You can use parentheses to override Excel’s built-in order of precedence. Expressions within parentheses are
always evaluated first.
The following formula uses parentheses to control the order in which the calculations occur. In this case,
cell B3 is subtracted from cell B2 and the result is multiplied by cell B4:
=(B2-B3)*B4
If you enter the formula without the parentheses, Excel computes a different answer. Because multiplication
has a higher precedence, cell B3 is multiplied by cell B4. Then this result is subtracted from cell B2, which
isn’t what was intended.
The formula without parentheses looks like this:
=B2-B3*B4
It’s a good idea to use parentheses even when they aren’t strictly necessary. Doing so helps to clarify what
the formula is intended to do. For example, the following formula makes it perfectly clear that B3 should be
multiplied by B4, and the result subtracted from cell B2. Without the parentheses, you would need to
remember Excel’s order of precedence.
=B2-(B3*B4)
You can also nest parentheses within formulas — that is, put them inside other parentheses. If you do so,
Excel evaluates the most deeply nested expressions first — and then works its way out. Here’s an example
of a formula that uses nested parentheses:
=((B2*C2)+(B3*C3)+(B4*C4))*B6
This formula has four sets of parentheses — three sets are nested inside the fourth set. Excel evaluates each
nested set of parentheses and then sums the three results. This result is then multiplied by the value in B6.
Although the preceding formula uses four sets of parentheses, only the outer set is really necessary. If you
understand operator precedence, it should be clear that you can rewrite this formula as:
=(B2*C2+B3*C3+B4*C4)*B6
Again, using the extra parentheses makes the calculation much clearer.
Every left parenthesis, of course, must have a matching right parenthesis. If you have many levels of nested
parentheses, keeping them straight can sometimes be difficult. If the parentheses don’t match, Excel displays
a message explaining the problem — and won’t let you enter the formula.
In some cases, if your formula contains mismatched parentheses, Excel may propose a correction to your

formula. Figure 15-1 shows an example of the Formula AutoCorrect feature. You may be tempted simply to
accept the proposed correction, but be careful — in many cases, the proposed formula, although syntacti-
cally correct, isn’t the formula you intended, and it will produce an incorrect result.
FIGURE 15-1
Excel’s Formula AutoCorrect feature often suggests a correction to an erroneous formula.
340
Making the Numbers Work with Excel
Part III
21 046913 ch15.qxp 5/2/07 9:07 PM Page 340
Excel lends a hand in helping you match parentheses. When the insertion point moves over a
parenthesis while you’re editing a cell, Excel momentarily bolds it — and does the same with
its matching parenthesis.
Using functions in your formulas
Most formulas you create use worksheet functions. These functions enable you to greatly enhance the
power of your formulas and perform calculations that are difficult (or even impossible) if you use only the
operators discussed previously. For example, you can use the
TAN function to calculate the tangent of an
angle. You can’t do this calculation by using only the mathematical operators.
Examples of formulas that use functions
A worksheet function can simplify a formula significantly. To calculate the average of the values in 10 cells
(A1:A10) without using a function, you’d have to construct a formula like this:
=(A1+A2+A3+A4+A5+A6+A7+A8+A9+A10)/10
Not very pretty, is it? Even worse, you would need to edit this formula if you added another cell to the
range. Fortunately, you can replace this formula with a much simpler one that uses one of Excel’s built-in
worksheet functions:
=AVERAGE(A1:A10)
The following formula demonstrates how using a function can enable you to perform calculations that
would not be possible otherwise. If (for example) you need to determine the largest value in a range, a for-
mula can’t tell you the answer without using a function. Here’s a simple formula that returns the largest
value in the range A1:D100:

=MAX(A1:D100)
Functions also can sometimes eliminate manual editing. Assume that you have a worksheet that contains
1,000 names in cells A1:A1000, and all names appear in all-capital letters. Your boss sees the listing and
informs you that the names will be mail-merged with a form letter — so all uppercase is not acceptable; for
example,
JOHN F. SMITH must appear as John F. Smith. You could spend the next several hours re-
entering the list — or you could use a formula such as the following, which uses a function to convert the
text in cell A1 to the proper case:
=PROPER(A1)
Enter this formula once in cell B1 and then copy it down to the next 999 rows. Then select B1:B1000 and
use Home ➪ Clipboard ➪ Copy to copy the range. Next, with B1:B1000 still selected, use Home ➪
Clipboard ➪ Paste Values to convert the formulas to values. Delete the original column, and you’ve just
accomplished several hours of work in less than a minute.
One last example should convince you of the power of functions. Suppose you have a worksheet that calcu-
lates sales commissions. If the salesperson sold more than $100,000 of product, the commission rate is 7.5
percent; otherwise the commission rate is 5.0 percent. Without using a function, you would have to create
two different formulas and make sure that you used the correct formula for each sales amount. A better
solution is to write a formula that uses the
IF function to ensure that you calculate the correct commission,
regardless of sales amount:
=IF(A1<100000,A1*5%,A1*7.5%)
This formula performs some simple decision-making. The formula checks the value of cell A1. If this value
is less than 100,000, the formula returns cell A1 multiplied by 5 percent. Otherwise it returns what’s in cell
A1, multiplied by 7.5 percent.
TIP
TIP
341
Introducing Formulas and Functions
15
21 046913 ch15.qxp 5/2/07 9:07 PM Page 341

Function arguments
In the preceding examples, you may have noticed that all the functions used parentheses. The information
inside the parentheses is called the list of arguments.
Functions vary in how they use arguments. Depending on what it has to do, a function may use
n
No arguments
n
One argument
n
A fixed number of arguments
n
An indeterminate number of arguments
n
Optional arguments
An example of a function that doesn’t use an argument is the
NOW function, which returns the current date
and time. Even if a function doesn’t use an argument, you must still provide a set of empty parentheses,
like this:
=NOW()
If a function uses more than one argument, you must separate each argument with a comma. The examples
at the beginning of the chapter used cell references for arguments. Excel is quite flexible when it comes to
function arguments, however. An argument can consist of a cell reference, literal values, literal text strings,
expressions, and even other functions.
A comma is the list-separator character for the U.S. version of Excel. Some other versions may
use a semicolon. The list separator is a Windows setting, which can be adjusted in the
Windows Control Panel (the Regional and Language Options dialog box).
NOTE
NOTE
342
Making the Numbers Work with Excel

Part III
New Functions in Excel 2007
E
xcel 2007 contains five new functions:
n
IFERROR — Used to check for an error, and display a message or perform a different calculation.
n
AVERAGEIF — Used to calculate a conditional average (similar to SUMIF and COUNTIF).
n
AVERAGEIFS — Used to calculate a conditional average using multiple criteria.
n
SUMIFS — Used to calculate a conditional sum using multiple criteria.
n
COUNTIFS — Used to calculate a conditional COUNT using multiple criteria.
In addition, worksheet functions that formerly required the Analysis ToolPak add-in (which is shipped with
Excel) are now built into Excel. So you have access to dozens of additional functions without installing the
add-in.
These new functions are described in detail in the Excel Help.
Keep in mind that if you use any of these new functions, you may not be able to share your workbook with
someone who uses an earlier version of Excel, unless that person has installed the Analysis ToolPak add-in.
21 046913 ch15.qxp 5/2/07 9:07 PM Page 342
More about functions
All told, Excel includes 340 functions. And if that’s not enough, you can purchase additional specialized
functions from third-party suppliers — and even create your own custom functions (by using VBA) if you’re
so inclined.
Some users feel a bit overwhelmed by the sheer number of functions, but you’ll probably find that you use
only a dozen or so on a regular basis. And as you’ll see, Excel’s Insert Function dialog box (described later
in this chapter) makes it easy to locate and insert a function, even if it’s not one that you use frequently.
You’ll find examples of Excel’s built-in functions in Chapters 16 and 17.
Entering Formulas into Your Worksheets

As I mentioned earlier, a formula must begin with an equal sign to inform Excel that the cell contains a for-
mula rather than text. Excel provides two ways to enter a formula into a cell: manually or by pointing to cell
references. The following sections discuss each way in detail.
Excel 2007 provides additional assistance when you create formulas by displaying a drop-down
list that contains function names and range names. The items displayed in the list are determined
by what you’ve already typed. For example, if you’re entering a formula and type the letter T, you’ll see the
drop-down list shown in Figure 15-2. If you type an additional letter, the list is shortened to show only the
matching functions. To have Excel
AutoComplete
an entry in that list, use the arrow keys to highlight the entry,
and then press Tab. Notice that highlighting a function in the list also displays a brief description of the func-
tion. See the sidebar “Using Formula AutoComplete” for an example of how this new feature works.
FIGURE 15-2
Excel 2007 displays a drop-down list when you enter a formula.
Entering formulas manually
Entering a formula manually involves, well, entering a formula manually. In a selected cell, you simply type
an equal sign (=) followed by the formula. As you type, the characters appear in the cell and in the Formula
bar. You can, of course, use all the normal editing keys when entering a formula.
NEW FEATURE
NEW FEATURE
CROSS-REF
CROSS-REF
343
Introducing Formulas and Functions
15
21 046913 ch15.qxp 5/2/07 9:07 PM Page 343
Entering formulas by pointing
Even though you can enter formulas by typing in the entire formula, Excel provides another method of
entering formulas that is generally easier, faster, and less error-prone. This method still involves some
manual typing, but you can simply point to the cell references instead of typing their values manually.

For example, to enter the formula =A1+A2 into cell A3, follow these steps:
1. Move the cell pointer to cell A3.
2. Type an equal sign (=) to begin the formula. Notice that Excel displays Enter in the status bar
(bottom left of your screen).
3. Press the up arrow twice. As you press this key, Excel displays a faint moving border around cell
A1, and the cell reference appears in cell A3 and in the Formula bar. In addition, Excel displays
Point in the status bar.
4. Type a plus sign (+). A solid-color border replaces the faint border, and Enter reappears in
the status bar.
344
Making the Numbers Work with Excel
Part III
Using Formula AutoComplete
T
he Formula AutoComplete feature in Excel 2007 makes entering formulas easier than ever. Here’s a quick
walk-through that demonstrates how it works. The goal is to create a formula that uses the
SUBTOTAL
function to calculate the average value in a range named TestScores.
1. Activate an empty cell and type an equal sign (=) to signal the start of a formula.
2. Type the letter S, and you’ll get a list of functions and names that begin with
S
. This feature is not
case-sensitive, so you can use either uppercase or lowercase characters.
3. Type the second letter, U. The list is filtered to show only functions and names that begin with
SU
.
4.
SUBTOTAL is second on the list, so use the Down Arrow to highlight the function and press Tab.
Excel adds the opening parenthesis and displays another list that contains options for the first
argument for

SUBTOTAL.
5. Use the Down Arrow to select
AVERAGE and press Tab. Excel inserts 101, the code for calculating
the average.
6. Type a comma to separate the next argument.
7. Type a T, and you get a list of functions and names that begin with
T
. You’re looking for
TestScores, so narrow it down a bit by typing the second character (e).
8. Highlight
TestScores and press Tab.
9. Finally, type a closing parenthesis and press Enter.
Formula AutoComplete includes the following items (and each type is identified by a separate icon):
n
Excel built-in functions
n
User defined functions (Functions defined by the user through VBA or other methods)
n
Defined Names (named using the Formulas
➪ Defined Names ➪ Define Name command).
n
Enumerated Arguments (only a few functions use such arguments, and
SUBTOTAL is one of them)
n
Table structure references (used to identify portions of a table)
21 046913 ch15.qxp 5/2/07 9:07 PM Page 344
5. Press the up arrow again, which puts the moving border around cell A2, and adds that cell
address to the formula.
6. Press Enter to end the formula.
You also can point to the data cells by using your mouse.

Pasting range names into formulas
If your formula uses named cells or ranges, you can either type the name in place of the address or choose
the name from a list and have Excel insert the name for you automatically. Two ways to insert a name into a
formula are available:
n
Select the name from the drop-down list: To use this method, you must know at least the first
character of the name. When you’re entering the formula, type the first character and then select
the name from the drop-down list that appears.
n
Press F3: This key displays the Paste Name dialog box. Select the name from the list and click
OK (or just double-click the name). Excel will enter the name into your formula. If no names are
defined, pressing F3 has no effect.
Figure 15-3 shows an example. The worksheet contains two defined names:
Expenses and Sales. The
Paste Name dialog box is being used to insert a name (
Sales) into the formula being entered in cell B11.
Refer to Chapter 14 for information about defining names.
FIGURE 15-3
You can use the Paste Name dialog box to quickly enter a defined name into a formula.
Inserting functions into formulas
The easiest way to enter a function into a formula is to use the drop-down list that Excel displays while you
type a formula. In order to use this method, however, you must know at least the first character of the func-
tion’s name.
CROSS-REF
CROSS-REF
TIP
TIP
345
Introducing Formulas and Functions
15

21 046913 ch15.qxp 5/2/07 9:07 PM Page 345
Another way to insert a function is to use the Function Library group on the Formulas tab (see Figure 15-4).
This is especially useful if you can’t remember which function you need. Click the function category
(Financial, Logical, Text, etc.) and you’ll get a list of the functions in that category. Click the function you
want, and Excel displays its Function Arguments dialog box. This is where you enter the function’s argu-
ments. In addition, you can click the Help On This Function link to learn more about the selected function.
FIGURE 15-4
You can insert a function by selecting it from one of the function categories.
Yet another way to insert a function into a formula is to use Excel’s Insert Function dialog box (see Figure
15-5). You can access this dialog box in several ways:
n
By using the Formulas ➪ Function Library ➪ Insert Function command.
n
By clicking the Insert Function icon, which is directly to the left of the Formula bar. This button
displays
fx.
n
By pressing Shift+F3.
FIGURE 15-5
The Insert Function dialog box.
The Insert Function dialog box shows a drop-down list of function categories. Select a category, and the
functions in that category are displayed in the list box. To access a function that you’ve used recently, select
Most Recently Used from the drop-down list.
346
Making the Numbers Work with Excel
Part III
21 046913 ch15.qxp 5/2/07 9:07 PM Page 346
If you’re not sure which function you need, you can search for the appropriate function by using the Search
For A Function box at the top of the dialog box. Enter your search terms, click Go, and you’ll get a list of
relevant functions. When you select a function in the Select A Function list box, Excel displays the function

(and its argument names) in the dialog box along with a brief description of what the function does.
When you locate the function you want to use, highlight it and click OK. Excel then displays its Function
Arguments dialog box, as shown in Figure 15-6. Use this dialog box to specify the arguments for the func-
tion. The dialog box will vary, depending on the function you’re inserting, and it will show one text box for
each of the function’s arguments. To use a cell or range reference as an argument, you can enter the address
manually or click inside the argument box and then select (that is, point to) the cell or range in the sheet).
After you’ve specified all the function arguments, click OK.
FIGURE 15-6
The Function Arguments dialog box.
Yet another way to insert a function while you’re entering a formula is to use the Function List
to the left of the Formula bar. When you are entering or editing a formula, the space normally
occupied by the Name box displays a list of the functions you’ve used most recently. After you select a func-
tion from this list, Excel displays the Function Arguments dialog box.
Function entry tips
Following are some additional tips to keep in mind when you use the Insert Function dialog box to enter
functions:
n
You can use the Insert Function dialog box to insert a function into an existing formula. Just edit
the formula and move the insertion point to the location at which you want to insert the function.
Then open the Insert Function dialog box (using any of the methods described above) and select
the function.
n
You can also use the Function Arguments dialog box to modify the arguments for a function in an
existing formula. Click the function in the Formula bar and then click the Insert Function button
(the fx button, to the left of the Formula bar).
n
If you change your mind about entering a function, click the Cancel button.
n
How many boxes you see in the Function Arguments dialog box depends on the number of argu-
ments used in the function you selected. If a function uses no arguments, you won’t see any boxes.

If the function uses a variable number of arguments (such as the
AVERAGE function), Excel adds a
new box every time you enter an optional argument.
TIP
TIP
347
Introducing Formulas and Functions
15
21 046913 ch15.qxp 5/2/07 9:07 PM Page 347
n
As you provide arguments in the Function Argument dialog box, the value of each argument is
displayed to the right of each box.
n
A few functions, such as
INDEX, have more than one form. If you choose such a function, Excel
displays another dialog box that lets you choose which form you want to use.
n
As you become familiar with the functions, you can bypass the Insert Function dialog box and
enter the function directly. Excel prompts you with argument names as you enter the function.
Editing Formulas
After you’ve entered a formula, you can (of course) edit that formula. You may need to edit a formula if you
make some changes to your worksheet and then have to adjust the formula to accommodate the changes.
Or the formula may return an error value, in which case you edit the formula to correct the error.
The following are some of the ways to get into cell edit mode:
n
Double-click the cell, which enables you to edit the cell contents directly in the cell.
n
Press F2, which enables you to edit the cell contents directly in the cell.
n
Select the cell that you want to edit, and then click in the Formula bar. This enables you to edit

the cell contents in the Formula bar.
n
If the cell contains a formula that returns an error, Excel will display a small triangle in the upper-
left corner of the cell. Activate the cell, and you’ll see an Error Checking button. Click the Error
Checking button, and you can choose one of the options for correcting the error. (The options
will vary according to the type of error in the cell.)
You can control whether Excel displays error indicators in the Formulas section of the Excel
Options dialog box. To display this dialog box, select Office Button ➪ Excel Options. Click
Formulas. If you remove the check mark from Enable Background Error Checking, Excel no longer displays
the error indicators or the Error Checking button.
While you’re editing a formula, you can select multiple characters either by dragging the mouse cursor over
them or by pressing Shift while you use the direction keys.
If you have a formula that you can’t seem to edit correctly, you can convert the formula to text
and tackle it again later. To convert a formula to text, just remove the initial equal sign (=).
When you’re ready to try again, type the initial equal sign to convert the cell contents back into a formula.
Using Cell References in Formulas
Most formulas you create include references to cells or ranges. These references enable your formulas to
work dynamically with the data contained in those cells or ranges rather than being restricted to fixed val-
ues. For example, if your formula refers to cell A1 and you change the value contained in A1, the formula
result changes to reflect the new value. If you didn’t use references in your formulas, you would need to edit
the formulas themselves in order to change the values used in the formulas.
Using relative, absolute, and mixed references
When you use a cell (or range) reference in a formula, you can use three types of references:
TIP
TIP
TIP
TIP
348
Making the Numbers Work with Excel
Part III

21 046913 ch15.qxp 5/2/07 9:07 PM Page 348
n
Relative: The row and column references can change when you copy the formula to another cell
because the references are actually offsets from the current row and column.
n
Absolute: The row and column references do not change when you copy the formula because the
reference is to an actual cell address.
n
Mixed: Either the row or column reference is relative, and the other is absolute.
An absolute reference uses two dollar signs in its address: one for the column letter and one for the row
number (for example, $A$5). Excel also allows mixed references in which only one of the address parts is
absolute (for example, $A4 or A$4).
By default, Excel creates relative cell references in formulas. The distinction becomes apparent when you
copy a formula to another cell.
Figure 15-7 shows a simple worksheet. The formula in cell D2, which multiplies the quantity by the price, is:
=B2*C2
This formula uses relative cell references. Therefore, when the formula is copied to the cells below it, the
references adjust in a relative manner. For example, the formula in cell D3 is:
=B3*C3
FIGURE 15-7
Copying a formula that contains relative references.
But what if the cell references in D2 contained absolute references, like this?
=$B$2*$C$2
In this case, copying the formula to the cells below would produce incorrect results. The formula in cell D3
would be exactly the same as the formula in cell D2.
Now I’ll extend the example to calculate sales tax, which is stored in cell B7 (see Figure 15-8). In this situa-
tion, the formula in cell D2 is:
=B2*C2*$B$7
The quantity is multiplied by the price, and the result is multiplied by the sales-tax rate stored in cell B7.
Notice that the reference to B7 is an absolute reference. When the formula in D2 is copied to the cells

below it, cell D3 will contain this formula:
=B3*C3*$B$7
Here, the references to cells B2 and C2 were adjusted, but the reference to cell B7 was not — which is
exactly what I want.
349
Introducing Formulas and Functions
15
21 046913 ch15.qxp 5/2/07 9:07 PM Page 349
FIGURE 15-8
Formula references to the sales tax cell should be absolute.
Figure 15-9 demonstrates the use of mixed references. The formulas in the C3:F7 range calculate the area
for various lengths and widths. The formula in cell C3 is:
=$B3*C$2
FIGURE 15-9
Using mixed cell references.
Notice that both cell references are mixed. The reference to cell B3 uses an absolute reference for the col-
umn ($B), and the reference to cell C2 uses an absolute reference for the row ($2). As a result, this formula
can be copied down and across, and the calculations will be correct. For example, the formula in cell F7 is:
=$B7*F$2
If C3 used either absolute or relative references, copying the formula would produce incorrect results.
When you cut and paste a formula (move it to another location), the cell references in the
formula aren’t adjusted. Again, this is usually what you want to happen. When you move a
formula, you generally want it to continue to refer to the original cells.
Changing the types of your references
You can enter nonrelative references (that is, absolute or mixed) manually by inserting dollar signs in the
appropriate positions of the cell address. Or you can use a handy shortcut: the F4 key. When you’ve entered
a cell reference (by typing it or by pointing), you can press F4 repeatedly to have Excel cycle through all
four reference types.
NOTE
NOTE

350
Making the Numbers Work with Excel
Part III
21 046913 ch15.qxp 5/2/07 9:07 PM Page 350
For example, if you enter =A1 to start a formula, pressing F4 converts the cell reference to =$A$1. Pressing
F4 again converts it to
=A$1. Pressing it again displays =$A1. Pressing it one more time returns to the origi-
nal
=A1. Keep pressing F4 until Excel displays the type of reference that you want.
When you name a cell or range, Excel (by default) uses an absolute reference for the name.
For example, if you give the name
SalesForecast to A1:A12, the Refers To box in the New
Name dialog box lists the reference as
$A$1:$A$12. This is almost always what you want. If you copy a cell
that has a named reference in its formula, the copied formula contains a reference to the original name.
Referencing cells outside the worksheet
Formulas can also refer to cells in other worksheets — and the worksheets don’t even have to be in the same
workbook. Excel uses a special type of notation to handle these types of references.
Referencing cells in other worksheets
To use a reference to a cell in another worksheet in the same workbook, use this format:
SheetName!CellAddress
In other words, precede the cell address with the worksheet name, followed by an exclamation point. Here’s
an example of a formula that uses a cell on the
Sheet2 worksheet:
=A1*Sheet2!A1
This formula multiplies the value in cell A1 on the current worksheet by the value in cell A1 on Sheet2.
If the worksheet name in the reference includes one or more spaces, you must enclose it in
single quotation marks. (Excel does that automatically if you use the point-and-click method.)
For example, here’s a formula that refers to a cell on a sheet named
All Depts:

=A1*’All Depts’! A1
Referencing cells in other workbooks
To refer to a cell in a different workbook, use this format:
=[WorkbookName]SheetName!CellAddress
In this case, the workbook name (in square brackets), the worksheet name, and an exclamation point pre-
cede the cell address. The following is an example of a formula that uses a cell reference in the
Sheet1
worksheet in a workbook named Budget:
=[Budget.xlsx]Sheet1!A1
If the workbook name in the reference includes one or more spaces, you must enclose it (and the sheet
name) in single quotation marks. For example, here’s a formula that refers to a cell on
Sheet1 in a work-
book named
Budget For 2008:
=A1*’[Budget For 2008.xlsx]Sheet1’!A1
When a formula refers to cells in a different workbook, the other workbook doesn’t have to be open. If the
workbook is closed, however, you must add the complete path to the reference so that Excel can find it.
Here’s an example:
=A1*’C:\My Documents\[Budget For 2008.xlsx]Sheet1’!A1
TIP
TIP
NOTE
NOTE
351
Introducing Formulas and Functions
15
21 046913 ch15.qxp 5/2/07 9:07 PM Page 351
A linked file can also reside on another system that’s accessible on your corporate network. The formula
below, for example, refers to a cell in a workbook in the files directory of a computer named
DataServer.

=’\\DataServer\files\[budget.xlsx]Sheet1’!$D$7
To create formulas that refer to cells not in the current worksheet, point to the cells rather
than entering their references manually. Excel takes care of the details regarding the workbook
and worksheet references. The workbook you’re referencing in your formula must be open if you’re going to
use the pointing method.
If you point to a different worksheet or workbook when creating a formula, you’ll notice that
Excel always inserts absolute cell references. Therefore, if you plan to copy the formula to
other cells, make sure that you change the cell references to relative before you copy it.
Using Formulas in Tables
One of the most significant new features in Excel 2007 is its support for tables. In this section I describe
how formulas work with tables.
Summarizing data in a table
Figure 15-10 shows a simple table with three columns. I entered the data, and then converted the range to
a table by choosing Insert ➪ Tables ➪ Table. Note that I didn’t define any names, but the table is named
Table1 by default.
FIGURE 15-10
A simple table with three columns.
If you’d like to calculate the total projected and total actual sales, you don’t even need to write a formula.
Simply click a button to add a row of summary formulas to the table:
1. Activate any cell in the table.
2. Place a check mark next to Table Tools ➪ Design ➪ Table Style Options ➪ Total Row.
NOTE
NOTE
TIP
TIP
352
Making the Numbers Work with Excel
Part III
21 046913 ch15.qxp 5/2/07 9:07 PM Page 352
3. Activate a cell in the Total Row and use the drop-down list to select the type of summary

formula to use (see Figure 15-11). For example, to calculate the sum of the Actual column,
select
SUM from the drop-down list in cell D15. Excel creates this formula:
=SUBTOTAL(109,[Actual])
For the SUBTOTAL function, 109 is an enumerated argument that represents SUM. The second argument for
the
SUBTOTAL function is the column name, in square brackets. Using the column name within brackets is
a new way to create “structured” references within a table. (I discuss this further in an upcoming section,
“Referencing data in a table.”)
FIGURE 15-11
A drop-down list enables you to select a summary formula for a table column.
You can toggle the Total Row display on and off by using Table Tools ➪ Design ➪ Table Style
Options ➪ Total Row. If you turn it off, the summary options you selected will be remembered
when you turn it back on.
Using formulas within a table
In many cases, you’ll want to use formulas within a table. For example, in the table shown in Figure 15-11,
you may want a column that shows the difference between the Actual and Projected amounts. As you’ll see,
Excel 2007 makes this very easy.
1. Activate cell E2 and type Difference for the column header. Excel automatically expands the
table for you.
2. Next move to cell E3 and type an equal sign to signify the beginning of a formula.
3. Press the left arrow key. Excel displays [Actual], which is the column heading, in the
Formula bar.
NOTE
NOTE
353
Introducing Formulas and Functions
15
21 046913 ch15.qxp 5/2/07 9:07 PM Page 353

×