Please Note: This article is written for users of the following Microsoft Excel versions: 97, 2000, 2002, and 2003. If you are using a later version (Excel 2007 or later), this tip may not work for you. For a version of this tip written specifically for later versions of Excel, click here: Finding and Replacing Error Values.

Finding and Replacing Error Values

by Allen Wyatt
(last updated November 3, 2012)

Lindsay often has huge worksheets with hundreds of rows of calculated values. Inevitably there will be scattered cells with the #N/A error that she would like to all be 0 (or some other value) so she can use the cells in other formulas. Due to the calculations Lindsay is running, she feels an IF formula or other such method to anticipate and remove these values from the calculation is usually impossible, and it's very tedious to remove them by hand. Lindsay wonders if there is any way to do the equivalent of a "find and replace" on those error values.

There are a couple of ways you can approach this issue. One is to use the Go To feature in Excel. Simply follow these steps:

  1. Press F5. Excel displays the Go To dialog box. (See Figure 1.)
  2. Figure 1. The Go To dialog box.

  3. Click Special. Excel displays the Go To Special dialog box. (See Figure 2.)
  4. Figure 2. The Go To Special dialog box.

  5. Make sure the Formulas radio button is selected.
  6. The only check box that should be selected under Formulas is Errors.
  7. Click OK. Excel selects all cells where the formula returned an error value.
  8. Type 0 or whatever value you want.
  9. Press Ctrl+Enter.

Note that this approach results in any error values being replaced, not just those with the #N/A error. If you have to make the replacements quite a bit or you want to only affect #N/A errors, you may want to use a macro to do the replacements:

Sub Replace_NAs()
    Dim C
    For Each C In ActiveSheet.UsedRange
        If Application.WorksheetFunction.IsNA(C) Then
            C.Value = 0
        End If
    Next
End Sub

You should note that all these options result in the formulas in the cells (those that returned the #N/A values) being permanently replaced with a 0 or whatever value you specify. The only way to not replace the formulas is to change those formulas to use an IF statement to check for the error condition before applying the formula.

ExcelTips is your source for cost-effective Microsoft Excel training. This tip (6905) applies to Microsoft Excel 97, 2000, 2002, and 2003. You can find a version of this tip for the ribbon interface of Excel (Excel 2007 and later) here: Finding and Replacing Error Values.

Author Bio

Allen Wyatt

With more than 50 non-fiction books and numerous magazine articles to his credit, Allen Wyatt is an internationally recognized author. He  is president of Sharon Parq Associates, a computer and publishing services company. ...

MORE FROM ALLEN

Continuing Macro Lines

Sometimes a macro command line can get very, very long. This can make it hard to understand when you look at it a month or so ...

Discover More

Getting the Proper Type of Ellipses

Type three periods in a row, and the AutoCorrect feature in Word kicks in to exchange that sequence for a special ellipses ...

Discover More

Selecting Fonts for a Chart

When formatting a chart, you might want to change the characteristics of the font used in various chart elements. This can be ...

Discover More

Solve Real Business Problems Master business modeling and analysis techniques with Excel and transform data into bottom-line results. This hands-on, scenario-focused guide shows you how to use the latest Excel tools to integrate data from multiple tables. Check out Microsoft Excel 2013 Data Analysis and Business Modeling today!

MORE EXCELTIPS (MENU)

Searching for Wildcards

Wildcard characters can be used within the Find and Replace tool, but what if you want to actually search for those wildcard ...

Discover More

Finding and Replacing in Text Boxes

Finding and replacing information in a worksheet is easy. Finding and replacing in other objects (such as text boxes or chart ...

Discover More

Finding Text in Text Boxes

Want to search for text that may appear in a text box rather than in a regular worksheet cell? You can only perform the ...

Discover More
Subscribe

FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."

View most recent newsletter.

Comments for this tip:

There are currently no comments for this tip. (Be the first to leave your comment—just use the simple form above!)

This Site

Got a version of Excel that uses the menu interface (Excel 97, Excel 2000, Excel 2002, or Excel 2003)? This site is for you! If you use a later version of Excel, visit our ExcelTips site focusing on the ribbon interface.

Subscribe

FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."

(Your e-mail address is not shared with anyone, ever.)

View the most recent newsletter.

Links and Sharing
Share