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

Understanding the For ... Next Structure

Spend any time creating Word macros, and sooner or later you will need to repeat some of your programming code a certain ...

Discover More

Noting Table Rows Containing a Character

If you want to have Word highlight rows in a table that contain a certain character, you need to resort to using a macro. ...

Discover More

Setting Default Attributes for Lines and Arrows

Don't like the way that Excel formats lines and arrows? You can easily make your own formatting changes, and then use your ...

Discover More

Comprehensive VBA Guide Visual Basic for Applications (VBA) is the language used for writing macros in all Office programs. This complete guide shows both professionals and novices how to master VBA in order to customize the entire Office suite for their needs. Check out Mastering VBA for Office 2010 today!

More ExcelTips (menu)

Checking for Messages in Cells

If you have a range of cells used to display error messages, you soon discover that it is easy to miss messages that may ...

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

Limitations On Finding Characters

When you search for information in a worksheet, you expect Excel to return results that make sense. If you don't get a search ...

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 two minus 2?

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.

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.