Chapter 32. Making Your Worksheets Error-Free

<feature><title>In This Chapter</title> </feature>

It goes without saying that you want your Excel worksheets to produce accurate results. Unfortunately, it’s not always easy to be certain that the results are correct—especially if you deal with large, complex worksheets. This chapter introduces the tools and techniques available to help identify, correct, and prevent errors.

Finding and Correcting Formula Errors

Making a change in a worksheet—even a relatively minor change—may produce a ripple effect that introduces errors in other cells. For example, accidentally entering a value into a cell that previously held a formula is all too easy to do. This simple error can have a major impact on other formulas, and you may not discover the problem until long after you make the change—or you may never discover the problem.

Formula errors tend to fall into one of the following general categories:

  • Syntax errors: You have a problem with the syntax of a formula. For example, a formula may have mismatched parentheses, or a function may not have the correct number of arguments.

  • Logical errors: A formula doesn’t return an error, but itcontains a logical flaw that causes it to return an incorrectresult.

  • Incorrect reference errors: The logic of the formula is correct, but the formula uses an incorrect cell reference. As a simple example, the range reference in a Sum formula may not include all the data that you want to sum.

  • Semantic errors: An example is a function name that is spelled incorrectly. Excel will attempt to interpret it as a name and will display the #NAME? error.

  • Circular references: A circular reference occurs when a formula refers to its own cell, either directly or indirectly. Circular references are useful in a few cases, but most of the time a circular reference indicates a problem.

  • Array formula entry error: When entering (or editing) an Array formula, you must use Ctrl+Shift+Enter to enter the formula. If you fail to do so, Excel doesn’t recognize the formula as an Array formula, and you may get an error or incorrect results.

  • Incomplete calculation errors: The formulas simply aren’t calculated fully. Microsoft has acknowledged some problems with Excel’s calculation engine in some versions of Excel. To ensure that your formulas are fully calculated, use Ctrl+Alt+F9.

Syntax errors are usually the easiest to identify and correct. In most cases, you’ll know when your formula contains a syntax error. For example, Excel won’t permit you to enter a formula with mismatched parentheses. Other syntax errors also usually result in an error display in the cell.

The following sections describe common formula problems and offers advice on identifying and correcting them.

Mismatched parentheses

In a formula, every left parenthesis must have a corresponding right parenthesis. If your formula has mismatched parentheses, Excel usually won’t permit you to enter it. An exception to this rule involves a simple formula that uses a function. For example, if you enter the following formula (which is missing a closing parenthesis), Excel accepts the formula and provides the missing parenthesis.

=SUM(A1:A500

A formula may have an equal number of left and right parentheses, but the parentheses may not match properly. For example, consider the following formula, which converts a text string such that the first character is uppercase and the remaining characters are lowercase. This formula has five pairs of parentheses, and they match properly.

=UPPER(LEFT(A1))&RIGHT(LOWER(A1),LEN(A1)-1)

The following formula also has five pairs of parentheses, but they are mismatched. The result displays a syntactically correct formula that simply returns the wrong result.

=UPPER(LEFT(A1)&RIGHT(LOWER(A1),LEN(A1)-1))

Often, parentheses that are in the wrong location will result in a syntax error—which is usually a message that tells you that you entered too many or too few arguments for a function.

Tip

Excel can help you out with mismatched parentheses. When you’re editing a formula and you move the cursor over a parenthesis, Excel displays it (and its matching parenthesis) in bold for about one-half second. In addition, Excel color codes nested parentheses while you are editing a formula.

Cells are filled with hash marks

A cell is filled with a series of hash marks (#) for one of two reasons:

  • The column is not wide enough to accommodate the formatted numeric value. To correct it, you can make the column wider or use a different number format.

  • The cell contains a formula that returns an invalid date or time. For example, Excel doesn’t support dates prior to 1900 or the use of negative time values. Attempting to display either of these values results in a cell filled with hash marks. Widening the column won’t fix it.

Blank cells are not blank

Some Excel users have discovered that by pressing the spacebar, the contents of a cell seem to erase. Actually, pressing the spacebar inserts an invisible space character, which isn’t the same as erasing the cell.

For example, the following formula returns the number of nonempty cells in range A1:A10. If you “erase” any of these cells by using the spacebar, these cells are included in the count, and the formula returns an incorrect result.

=COUNTA(A1:A10)

If your formula doesn’t ignore blank cells the way that it should, check to make sure that the blank cells are really blank cells. One way is to choose Home Blank cells are not blank Editing Blank cells are not blank Find & Select Blank cells are not blank Go To (or press F5 or Ctrl+G), which displays the Go To dialog box. Click the Special button and then choose the Blanks option in the Go To Special dialog box. Excel will select all blank cells so that you can spot cells that appear to be empty but are not.

Extra space characters

If you have formulas or use procedures that rely on comparing text, be careful that your text doesn’t contain additional space characters. Adding an extra space character is particularly common when data has been imported from another source.

Excel automatically removes trailing spaces from values that you enter, but trailing spaces in text entries are not deleted. It’s impossible to tell, just by looking at a cell, if text contains one or more trailing space characters.

Formulas returning an error

A formula may return any of the following error values:

  • #DIV/0!

  • #N/A

  • #NAME?

  • #NULL!

  • #NUM!

  • #REF!

  • #VALUE!

The following sections summarize possible problems that may cause these errors.

Tip

Excel allows you to choose how error values are printed. To access this feature, display the Page Setup dialog box and click the Sheet tab. You can choose to print error values as displayed (the default), or as blank cells, dashes, or #N/A. To display the Page Setup dialog box, click the dialog box launcher on the Page Layout Tip Page Setup group.

#DIV/0! errors

Division by zero is not a valid operation. If you create a formula that attempts to divide by zero, Excel displays its familiar #DIV/0! error value.

Because Excel considers a blank cell to be zero, you also get this error if your formula divides by a missing value. This problem is common when you create formulas for data that you haven’t entered yet, as shown in Figure 32.1. The formula in cell D2, which was copied to the cells below it, is

=(C2-B2)/C2
#DIV/0! errors occur when the data in column C is missing.

Figure 32.1. #DIV/0! errors occur when the data in column C is missing.

This formula calculates the percent change between the values in columns B and C. Data isn’t available for months beyond May, so the formula returns a #DIV/0! error.

To avoid the error display, you can use an IF function to check for a blank cell in column C:

= IF(C2=0,"",(C2-B2)/C2)

This formula displays an empty string if cell C2 is blank or contains 0; otherwise, it displays the calculated value.

Another approach is to use an IFERROR function to check for any error condition. The following formula, for example, displays an empty string if the formula results in any type of error.

=IFERROR((C2-B2)/C2,"")

New Feature

The IFERROR function is new to Excel 2007. For compatibility with previous versions, use this formula:

=IF(ISERROR((C2-B2)/C2),"",(C2-B2)/C2)

#N/A errors

The #N/A error occurs if any cell referenced by a formula displays #N/A.

Note

Some users like to enter =NA() or #N/A explicitly for missing data. This method makes it perfectly clear that the data is not available and hasn’t been deleted accidentally.

The #N/A error also occurs when a LOOKUP function (HLOOKUP, LOOKUP, MATCH, or VLOOKUP) can’t find a match.

#NAME? errors

The #NAME? error occurs under these conditions:

  • The formula contains an undefined range or cell name.

  • The formula contains text that Excel interprets as an undefined name. A misspelled function name, for example, generates a #NAME? error.

  • The formula uses a worksheet function that’s defined in an add-in, and the add-in is not installed.

Note

Excel has a bit of a problem with range names. If you delete a name for a cell or range and the name is used in a formula, the formula continues to use the name, even though it’s no longer defined. As a result, the formula displays #NAME?. You may expect Excel to automatically convert the names to their corresponding cell references, but this doesn’t happen.

#NULL! errors

The #NULL! error occurs when a formula attempts to use an intersection of two ranges that don’t actually intersect. Excel’s intersection operator is a space. The following formula, for example, returns #NULL! because the two ranges don’t intersect.

=SUM(B5:B14 A16:F16)

The following formula doesn’t return #NULL! but displays the contents of cell B9—which represents the intersection of the two ranges.

=SUM(B5:B14 A9:F9)

#NUM! errors

A formula returns a #NUM! error if any of the following occurs:

  • You pass a non-numeric argument to a function when a numeric argument is expected.

  • You pass an invalid argument to a function. For example, this formula returns #NUM!:

    =SQRT(-12)
  • A function that uses iteration can’t calculate a result. Examples of functions that use iteration are IRR and RATE.

  • A formula returns a value that is too large or too small. Excel supports values between –1E-307 and 1E+307.

#REF! errors

The #REF! error occurs when a formula uses an invalid cell reference. This error can occur in the following situations:

  • You delete a cell that is referenced by the formula. For example, the following formula displays a #REF! error if row 1, column A, or column B is deleted.

    =A1/B1
  • You copy a formula to a location that invalidates the relative cell references. For example, if you copy the following formula from cell A2 to cell A1, the formula returns #REF! because it attempts to refer to a nonexistent cell.

    =A1-1
  • You cut a cell (by choosing Home #REF! errors Clipboard #REF! errors Cut) and then paste it to a cell that’s referenced by a formula. The formula will display #REF!.

#VALUE! errors

The #VALUE! error is very common and can occur under the following conditions:

  • An argument for a function is of an incorrect data type, or the formula attempts to perform an operation using incorrect data. For example, a formula that adds a value to a text string returns the #VALUE! error.

  • A function’s argument is a range when it should be a single value.

  • A custom worksheet function is not calculated. You can use Ctrl+Alt+F9 to force a recalculation.

  • A custom worksheet function attempts to perform an operation that is not valid. For example, custom functions can’t modify the Excel environment or make changes to other cells.

  • You forget to press Ctrl+Shift+Enter when entering an Array formula.

Absolute/relative reference problems

As described in Chapter 11, a cell reference can be relative (for example, A1), absolute (for example, $A$1), or mixed (for example, $A1 or A$1). The type of cell reference that you use in a formula is relevant only if the formula will be copied to other cells.

A common problem is using a relative reference when you should use an absolute reference. As shown in Figure 32.2, cell C1 contains a tax rate, which is used in the formulas in column C. The formula in cell C4 is

=B4+(B4*$C$1)
Formulas in the range C4:C7 use an absolute reference to cell C1.

Figure 32.2. Formulas in the range C4:C7 use an absolute reference to cell C1.

Notice that the reference to cell C1 is an absolute reference. When the formula is copied to other cells in column C, the formula continues to refer to cell C1. If the reference to cell C1 were a relative reference, the copied formulas would return an incorrect result.

Operator precedence problems

Excel has some straightforward rules about the order in which mathematical operations are performed (see Chapter 11). When in doubt (or when you simply need to clarify your intentions), you should use parentheses to ensure that operations are performed in the correct order. For example, the following formula multiplies A1 by A2 and then adds 1 to the result. The multiplication is performed first because it has a higher order of precedence.

= 1+A1*A2

The following is a clearer version of this formula. The parentheses aren’t necessary, but in this case, the order of operations is perfectly obvious.

=1+(A1*A2)

Notice that the negation operator symbol is exactly the same as the subtraction operator symbol. This, as you may expect, can cause some confusion. Consider these two formulas:

=-3^2
=0-3^2

The first formula, as expected, returns 9. The second formula, however, returns –9. Squaring a number always produces a positive result, so how is it that Excel can return the –9 result?

In the first formula, the minus sign is a negation operator and has the highest precedence. However, in the second formula, the minus sign is a subtraction operator, which has a lower precedence than the exponentiation operator. Therefore, the value 3 is squared, and the result is subtracted from zero, which produces a negative result.

Using parentheses, as shown in the following formula, causes Excel to interpret the operator as a minus sign rather than a negation operator. This formula returns –9.

=-(3^2)

Formulas are not calculated

If you use custom worksheet functions written in VBA, you may find that formulas that use these functions fail to get recalculated and may display incorrect results. To force a single formula to be recalculated, select the cell, press F2, and then press Enter. To force a recalculation of all formulas, press Ctrl+Alt+F9.

Actual versus displayed values

You may encounter a situation in which values in a range don’t appear to add up properly. For example, Figure 32.3 shows a worksheet with the following formula entered into each cell in the range B3:B5:

=1/3
A simple demonstration of numbers that appear to add up incorrectly.

Figure 32.3. A simple demonstration of numbers that appear to add up incorrectly.

Cell B6 contains the following formula:

=SUM(B3:B5)

All the cells are formatted to display with three decimal places. As you can see, the formula in cell B6 appears to display an incorrect result. (You may expect it to display 0.999.) The formula, of course, does return the correct result. The formula uses the actual values in the range B3:B5, not the displayed values. You can instruct Excel to use the displayed values by checking the Set Precision As Displayed check box on the Advanced section of the Excel Options dialog box. (Choose Office A simple demonstration of numbers that appear to add up incorrectly. Excel Options to display this dialog box.)

Caution

Be very careful with the Set Precision As Displayed option. This option also affects normal values (nonformulas) that have been entered into cells. For example, if a cell contains the value 4.68 and is displayed with no decimal places (that is, 5), checking the Precision As Displayed check box converts 4.68 to 5.00. This change is permanent, and you can’t restore the original value if you later uncheck the Set Precision As Displayed check box. A better approach is to use Excel’s ROUND function to round off the values to the desired number of decimal places.

Floating point number errors

Computers, by their very nature, don’t have infinite precision. Excel stores numbers in binary format by using eight bytes, which can handle numbers with 15-digit accuracy. Some numbers can’t be expressed precisely by using eight bytes, so the number stores as an approximation.

To demonstrate how this lack of precision may cause problems, enter the following formula into cell A1:

=(5.1-5.2)+1

The result should be 0.9. However, if you format the cell to display 15 decimal places, you discover that Excel calculates the formula with a result of 0.899999999999999. This result occurs because the operation in parentheses is performed first, and this intermediate result stores in binary format by using an approximation. The formula then adds 1 to this value, and the approximation error is propagated to the final result.

In many cases, this type of error doesn’t present a problem. However, if you need to test the result of that formula by using a logical operator, it may present a problem. For example, the following formula (which assumes that the previous formula is in cell A1) returns False:

=A1=.9

One solution to this type of error is to use Excel’s ROUND function. The following formula, for example, returns True because the comparison is made by using the value in A1 rounded to one decimal place.

=ROUND(A1,1)=0.9

Here’s another example of a “precision” problem. Try entering the following formula:

=(1.333-1.233)-(1.334-1.234)

This formula should return 0, but it actually returns –2.220446E-16 (a number very close to zero).

If that formula is in cell A1, the following formula returns Not Zero.

=IF(A1=0,"Zero","Not Zero")

One way to handle these “very close to zero” rounding errors is to use a formula like this:

=IF(ABS(A1)<1E-6,"Zero","Not Zero")

This formula uses the less-than (<) operator to compare the absolute value of the number with a very small number. This formula returns Zero.

“Phantom link” errors

You may open a workbook and see a message like the one shown in Figure 32.4. This message sometimes appears even when a workbook contains no linked formulas. Often, these phantom links are created when you copy a worksheet that contains names.

Excel’s way of asking you if you want to update links in a workbook.

Figure 32.4. Excel’s way of asking you if you want to update links in a workbook.

First, try choosing Office Excel’s way of asking you if you want to update links in a workbook. Prepare Excel’s way of asking you if you want to update links in a workbook. Edit Links To Files to display the Edit Links dialog box. Then select each link and click Break Link. If that doesn’t solve the problem, this phantom link may be caused by an erroneous name. Choose Formulas Excel’s way of asking you if you want to update links in a workbook. Defined Names Excel’s way of asking you if you want to update links in a workbook. Name Manager and scroll through the list of names. If you see a name that refers to #REF!, delete the name. The Name Manager dialog box has a Filter button that lets you filter the names. For example, you can filter the lists to display only the names with errors.

Using Excel’s Auditing Tools

Excel includes a number of tools that can help you track down formula errors. This section describes the auditing tools built into Excel.

Identifying cells of a particular type

The Go To Special dialog box is a handy tool that enables you to locate cells of a particular type. To display this dialog box, choose Home Identifying cells of a particular type Editing Identifying cells of a particular type Find & Select Identifying cells of a particular type Go To Special, which displays the Go To Special dialog box, as shown in Figure 32.5.

The Go To Special dialog box.

Figure 32.5. The Go To Special dialog box.

Note

If you select a multicell range before displaying the Go To Special dialog box, the command operates only within the selected cells. If a single cell is selected, the command operates on the entire worksheet.

You can use the Go To Special dialog box to select cells of a certain type, which can often help you identify errors. For example, if you choose the Formulas option, Excel selects all the cells that contain a formula. If you zoom the worksheet out to a small size, you can get a good idea of the worksheet’s organization (see Figure 32.6).

Zooming out and selecting all formula cells can give you a good overview of how the worksheet is designed.

Figure 32.6. Zooming out and selecting all formula cells can give you a good overview of how the worksheet is designed.

Tip

Selecting the formula cells may also help you to spot a common error—a formula that has been replaced accidentally with a value. If you find a cell that’s not selected amid a group of selected formula cells, chances are good that the cell previously contained a formula that has been replaced by a value.

Viewing formulas

You can become familiar with an unfamiliar workbook by displaying the formulas rather than the results of the formulas. To toggle the display of formulas, choose Formulas Viewing formulas Formula Auditing Viewing formulas Show Formulas. You may want to create a second window for the workbook before issuing this command. This way, you can see the formulas in one window and the results of the formula in the other window. Choose View Viewing formulas Window Viewing formulas New Window to open a new window.

Tip

You can also use Ctrl+` (that key is usually above the Tab key) to toggle between Formula view and Normal view.

Figure 32.7 shows an example of a worksheet displayed in two windows. The window on the top shows Normal view (formula results), and the window on the bottom displays the formulas. The View Tip Window Tip View Side By Side command, which allows synchronized scrolling, is also useful for viewing two windows (see Chapter 4 for more information about this command).

Displaying formulas (bottom window) and their results (top window).

Figure 32.7. Displaying formulas (bottom window) and their results (top window).

Tracing cell relationships

To understand how to trace cell relationships, you need to familiarize yourself with the following two concepts:

  • Cell precedents: Applicable only to cells that contain a formula, a formula cell’s precedents are all the cells that contribute to the formula’s result. A direct precedent is a cell that you use directly in the formula. An indirect precedent is a cell that isn’t used directly in the formula but is used by a cell that you refer to in the formula.

  • Cell dependents: These formula cells depend on a particular cell. A cell’s dependents consist of all formula cells that use the cell. Again, the formula cell can be a direct dependent or an indirect dependent.

For example, consider this simple formula entered into cell A4:

=SUM(A1:A3)

Cell A4 has three precedent cells (A1, A2, and A3), which are all direct precedents. Cells A1, A2, and A3 each have a dependent cell (cell A4), and they’re all direct dependents.

Identifying cell precedents for a formula cell often sheds light on why the formula isn’t working correctly. Conversely, knowing which formula cells depend on a particular cell is also helpful. For example, if you’re about to delete a formula, you may want to check to see whether it has any dependents.

Identifying precedents

You can identify cells used by a formula in the active cell in a number of ways:

  • Press F2. The cells that are used directly by the formula are outlined in color, and the color corresponds to the cell reference in the formula. This technique is limited to identifying cells on the same sheet as the formula.

  • Display the Go To Special dialog box (choose Home Identifying precedents Editing Identifying precedents Find & Select Identifying precedents Go To Special). Select the Precedents option and then select either Direct Only (for direct precedents only) or All Levels (for direct and indirect precedents). Click OK, and Excel selects the precedent cells for the formula. This technique is limited to identifying cells on the same sheet as the formula.

  • Press Ctrl+[ to select all direct precedent cells on the active sheet.

  • Press Ctrl+Shift+{ to select all precedent cells (direct and indirect) on the active sheet.

  • Choose Formulas Identifying precedents Formula Auditing Identifying precedents Trace Precedents, and Excel will draw arrows to indicate the cell’s precedents. Click this button multiple times to see additional levels of precedents. Choose Formulas Identifying precedents Formula Auditing Identifying precedents Remove Arrows to hide the arrows. Figure 32.8 shows a worksheet with precedent arrows drawn to indicate the precedents for the formula in cell C13.

This worksheet displays arrows that indicate cell precedents for the formula in cell C13.

Figure 32.8. This worksheet displays arrows that indicate cell precedents for the formula in cell C13.

Identifying dependents

You can identify formula cells that use a particular cell in a number of ways:

  • Display the Go To Special dialog box. Select the Dependents option and then select either Direct Only (for direct dependents only) or All Levels (for direct and indirect dependents). Click OK. Excel selects the cells that depend on the active cell. This technique is limited to identifying cells on the active sheet only.

  • Press Ctrl+] to select all direct dependent cells on the active sheet.

  • Press Ctrl+Shift+} to select all dependent cells (direct and indirect) on the active sheet.

  • Choose Formulas Identifying dependents Formula Auditing Identifying dependents Trace Dependents, and Excel will draw arrows to indicate the cell’s dependents. Click this button multiple times to see additional levels of dependents. Choose Formulas Identifying dependents Formula Auditing Identifying dependents Remove Arrows to hide the arrows.

Tracing error values

If a formula displays an error value, Excel can help you identify the cell that is causing that error value. An error in one cell is often the result of an error in a precedent cell. Activate a cell that contains an error value and choose Formulas Tracing error values Formula Auditing Tracing error values Error Checking Tracing error values Trace Error. Excel draws arrows to indicate the error source.

Fixing circular reference errors

If you accidentally create a circular reference formula, Excel displays a warning message, Circular Reference (with the cell address) in the status bar, and draws arrows on the worksheet to help you identify the problem. If you can’t figure out the source of the problem, use Formulas Fixing circular reference errors Formula Auditing Fixing circular reference errors Error Checking Fixing circular reference errors Circular References. This command displays a list of all cells that are involved in the circular references. Start by selecting the first cell listed and then work your way down the list until you figure out the problem.

Using background error-checking feature

Some people may find it helpful to take advantage of Excel’s automatic error-checking feature. This feature is enabled or disabled by using the check box labeled Enable Background Error Checking, on the Formulas tab in the Excel Options dialog box shown in Figure 32.9. In addition, you can specify which types of errors to check for by using the check boxes in the Error Checking Rules section.

Excel can check your formulas for potential errors.

Figure 32.9. Excel can check your formulas for potential errors.

When error checking is turned on, Excel continually evaluates your worksheet, including its formulas. If a potential error is identified, Excel places a small triangle in the upper-left corner of the cell. When the cell is activated, a Smart Tag appears. Clicking this Smart Tag provides you with options. Figure 32.10 shows the options that appear when you click the Smart Tag in a cell that contains a #DIV/0 error. The options vary, depending on the type of error.

After you click an error, Smart Tag gives you a list of options.

Figure 32.10. After you click an error, Smart Tag gives you a list of options.

In many cases, you will choose to ignore an error by selecting the Ignore Error option. Selecting this option eliminates the cell from subsequent error checks. However, all previously ignored errors can be reset so that they appear again. (Use the Reset Ignored Errors button in the Formulas tab of the Excel Options dialog box.)

You can choose Formulas After you click an error, Smart Tag gives you a list of options. Formula Auditing After you click an error, Smart Tag gives you a list of options. Error Checking to display a dialog box that describes each potential error cell in sequence, much like using a spell-checking command. This command is available even if you disable background error checking. Figure 32.11 shows the Error Checking dialog box. Note that this dialog box is modeless, so that you can still access your worksheet when the Error Checking dialog box is displayed.

Using the Error Checking dialog box to cycle through potential errors identified by Excel.

Figure 32.11. Using the Error Checking dialog box to cycle through potential errors identified by Excel.

Caution

It’s important to understand that the error-checking feature isn’t perfect. In fact, it’s not even close to perfect. In other words, you can’t assume that you have an error-free worksheet simply because Excel doesn’t identify any potential errors! Also, be aware that this error-checking feature won’t catch a very common type of error—that of overwriting a formula cell with a value.

Using Excel Formula Evaluator

Excel’s Formula Evaluator lets you see the various parts of a nested formula evaluated in the order that the formula is calculated. To use the Formula Evaluator, select the cell that contains the formula and choose Formula Using Excel Formula Evaluator Formula Auditing Using Excel Formula Evaluator Evaluate Formula to display the Evaluate Formula dialog box (see Figure 32.12).

Excel’s Formula Evaluator shows a formula being calculated one step at a time.

Figure 32.12. Excel’s Formula Evaluator shows a formula being calculated one step at a time.

Click the Evaluate button to show the result of calculating the expressions within the formula. Each click of the button performs another calculation. This feature may seem a bit complicated at first, but if you spend some time working with it, you’ll understand how it works and see the value.

Excel provides another way to evaluate a part of a formula:

  1. Select the cell that contains the formula.

  2. Press F2 to get into cell edit mode

  3. Use your mouse to highlight the portion of the formula you want to evaluate. Or, press Shift and use the arrow keys.

  4. Press F9.

The highlighted portion of the formula displays the calculated result. You can evaluate other parts of the formula or press Esc to cancel and return your formula to its previous state.

Caution

Be careful when using this technique, because if you press Enter (rather than Escape), the formula will be modified to use the calculated values.

Searching and Replacing

Excel has a powerful search and replace feature that makes it easy to locate information in a worksheet or across multiple worksheets in a workbook. As an option, you can also search for text and replace it with other text.

To access the Find And Replace dialog box, start by selecting the range that you want to search. If you select any single cell, Excel searches the entire sheet. Choose Home Searching and Replacing Editing Searching and Replacing Find & Select Searching and Replacing Find (or click Ctrl+F). You’ll see the dialog box shown in Figure 32.13. If you’re simply looking for information in the worksheet, click the Find tab. If you want to replace existing text with new text, use the Replace tab. Also note that you can use the Options button to display (or hide) additional options. The dialog box shown in the figure displays these additional options.

Use the Find And Replace dialog box to locate information in a worksheet or workbook.

Figure 32.13. Use the Find And Replace dialog box to locate information in a worksheet or workbook.

Searching for information

Enter the information to search for in the Find What text box and then specify any of the following options.

  • Use the Within drop-down list to specify where to search (the current sheet or the entire workbook).

  • Use the Search drop-down list to specify the direction (by rows or by columns).

  • Use the Look In drop-down list to specify what cell parts to search (formulas, values, or comments).

  • Use the Match Case check boxes to specify whether the search should be case sensitive.

  • Use the Match Entire Cell Contents check box to specify whether the entire cell contents must be matched.

  • Click the Format button to search for cells that have a particular formatting (see the upcoming “Searching for formatting” section).

Click Find Next to locate the matching cells one at a time or click Find All to locate all matches. If you use the Find All button, the Find And Replace dialog box expands to display the addresses of all matching cells in a list (see Figure 32.14). When you select an entry in this list, Excel scrolls the worksheet so that you can view it in context.

Displaying the result of a search in the Find And Replace dialog box.

Figure 32.14. Displaying the result of a search in the Find And Replace dialog box.

Tip

After using Find All, press Ctrl+A to select all the found cells.

Note

The Find And Replace dialog box is modeless. Therefore, you can access the worksheet and make changes without the need to dismiss the dialog box.

Replacing information

To replace text with other text, use the Replace tab in the Find And Replace dialog box. Enter the text to be replaced in the Find What field and then enter the new text in the Replace With field. Specify other options as described in the previous section.

Click Find Next to locate the first matching item and then click Replace to do the replacement. When you click the Replace button, Excel then locates the next matching item. To override the replacement, click Find Next. To replace all items without verification, click Replace All.

Tip

To delete information, enter the text to be deleted in the Find What field, and leave the Replace With field empty.

Searching for formatting

The Find And Replace dialog box also enables you to locate cells that contain a particular type of formatting. As an option, you can replace that formatting with another type of formatting. For example, assume that you want to locate all cells that are formatted as bold and then change that formatting to bold and italic. Follow these steps:

  1. Choose Home Searching for formatting Editing Searching for formatting Find & Select Searching for formatting Replace to display the Find And Replace dialog box (or press Ctrl+H).

  2. Make sure that the Replace tab is displayed.

  3. If the Find What and Replace With fields are not empty, delete their contents.

  4. Click the top Format button to display the Find Format dialog box. This dialog box resembles the standard Format Cells dialog box.

  5. In the Find Format dialog box, select the Font tab.

  6. Select Bold in the Font Style list and then click OK.

  7. Click the bottom Format button to display the Replace Format dialog box.

  8. In the Replace Format dialog box, select the Font tab.

  9. Select Bold Italic in the Font Style list and then click OK. At this point, the Find And Replace dialog box resembles Figure 32.15. Notice that it displays previews of the formatting that will be found and replaced.

    Using the Find And Replace dialog box to change formatting.

    Figure 32.15. Using the Find And Replace dialog box to change formatting.

  10. In the Find And Replace dialog box, click Replace All. Excel locates all cells that have bold formatting and changes the formatting to bold italic.

You can also find formatting based on a particular cell. In the Find Format dialog box, click the Choose Format From Cell button and then click the cell that contains the formatting you’re looking for.

Caution

The Find And Replace dialog box cannot find background color formatting in tables that was applied using table styles, or formatting that is applied based on Conditional Formatting.

Spell Checking Your Worksheets

If you use a word-processing program, you probably run its spell checker before printing an important document. Spelling mistakes can be just as embarrassing when they appear in a spreadsheet. Fortunately, Microsoft includes a spell checker with Excel.

To access the spell checker, choose Review Spell Checking Your Worksheets Proofing Spell Checking Your Worksheets Spelling, or press F7. To check the spelling in just a particular range, select the range before you activate the spell checker.

If the spell checker finds any words it does not recognize as correct, it displays the Spelling dialog box, shown in Figure 32.16.

Use the Spelling dialog box to locate and correct spelling errors in your worksheets.

Figure 32.16. Use the Spelling dialog box to locate and correct spelling errors in your worksheets.

Note

The spell checker checks cell contents, text in graphic objects and charts, and page headers and footers. Even the contents of hidden rows and columns are checked.

The Spelling dialog box works similarly to other spell checkers with which you may be familiar. If Excel encounters a word that isn’t in the current dictionary or that is misspelled, it offers a list of suggestions. You can respond by clicking one of these buttons:

  • Ignore Once: Ignores the word and continues the spell check.

  • Ignore All: Ignores the word and all subsequent occurrences of it.

  • Add To Dictionary: Adds the word to the dictionary.

  • Change: Changes the word to the selected word in the Suggestions list.

  • Change All: Changes the word to the selected word in the Suggestions list and changes all subsequent occurrences of it without asking.

  • AutoCorrect: Adds the misspelled word and its correct spelling (which you select from the list) to the AutoCorrect list.

Using AutoCorrect

AutoCorrect is a handy feature that automatically corrects common typing mistakes. You can also add to the list some words that Excel corrects automatically. The AutoCorrect dialog box appears in Figure 32.17. To access this feature, choose Office Using AutoCorrect Excel Options. In the Excel Options dialog box, click the Proofing tab and then click the AutoCorrect Options button.

Use the AutoCorrect dialog box to control the spelling corrections Excel makes automatically.

Figure 32.17. Use the AutoCorrect dialog box to control the spelling corrections Excel makes automatically.

This dialog box has several options:

  • Correct TWo INitial CApitals: Automatically corrects words with two initial uppercase letters. For example, BUdget is converted to Budget. This mistake is common among fast typists. You can click the Exceptions button to specify a list of exceptions to this rule.

  • Capitalize First Letter Of Sentences: Capitalizes the first letter in a sentence (all other letters are unchanged).

  • Capitalize Names Of Days: Capitalizes the days of the week. If you enter monday, Excel converts it to Monday.

  • Correct Accidental Use Of cAPS LOCK key: Corrects errors caused if you accidentally hit the CapsLock key while typing.

  • Replace Text As You Type: AutoCorrect automatically changes incorrect words as you type them.

Excel includes a long list of AutoCorrect entries for commonly misspelled words. In addition, it has AutoCorrect entries for some symbols. For example, (c) is replaced with © and (r) is replaced with ®. You can also add your own AutoCorrect entries. For example, if you find that you frequently misspell the word January as Janruary, you can create an AutoCorrect entry so that it’s changed automatically. To create a new AutoCorrect entry, enter the misspelled word in the Replace box and the correctly spelled word in the With box. You can also delete entries that you no longer need.

Tip

You also can use the AutoCorrect feature to create shortcuts for commonly used words or phrases. For example, if you work for a company named Consolidated Data Processing Corporation, you can create an AutoCorrect entry for an abbreviation, such as cdp. Then, whenever you type cdp, Excel automatically changes it to Consolidated Data Processing Corporation. Just make sure that you don’t use a combination of characters that might normally appear in your text.

Note

In some cases, you may want to override the AutoCorrect feature. For example, you may need to enter (c) rather than the copyright symbol. You can do so by clicking the Undo button on the Quick Access Toolbar (or by pressing Ctrl+Z).

You can use the AutoFormat As You Type tab of the AutoCorrect dialog box to control a few other automatic settings in Excel.

Use the Smart Tags tab to make Excel show Smart Tags—similar to hyperlinks—for certain types of data in your worksheets. The types of Smart Tags Excel recognizes vary depending on the types of software that are installed on your system.

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

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