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)

1

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

Fatal Errors in Word

If Word runs into a problem and the program can't continue, that can be distressing. Here are some things you can check to ...

Discover More

Get Rid of Web Stuff

When you copy information from a Web page and paste it into a worksheet, you can end up with more than you bargained for. ...

Discover More

Sheets for Days

Need a quick way to have a worksheet for each day in a month? Here's a macro that makes the worksheet creation a snap.

Discover More

Professional Development Guidance! Four world-class developers offer start-to-finish guidance for building powerful, robust, and secure applications with Excel. The authors show how to consistently make the right design decisions and make the most of Excel's powerful features. Check out Professional Excel Development today!

More ExcelTips (menu)

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

Searching by Columns, by Default

Do you often want to search through a worksheet by column rather than by row? Excel defaults to searching by row, of course, ...

Discover More

Making All Occurrences Bold

Want to make instances of a given word or phrase bold throughout a worksheet? Here's a way you can make the change quickly.

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

If you would like to add an image to your comment (not an avatar, but an image to help in making the point of your comment), include the characters [{fig}] in your comment text. You’ll be prompted to upload your image when you submit the comment. Images larger than 600px wide or 1000px tall will be reduced. Up to three images may be included in a comment. All images are subject to review. Commenting privileges may be curtailed if inappropriate images are posted.

What is four less than 8?

2017-07-15 04:42:29

Ken Endacott

The InBookmark function has an error. The line:
If Left(Selection.Bookmarks(J).Name) <> "_" Then
should be:
If Left(Selection.Bookmarks(J).Name, 1) <> "_" Then


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.

Newest Tips
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.