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

Deleting Unwanted Styles

Custom styles can be a great help in formatting a worksheet. You may, at some point, want to get rid of all the custom styles ...

Discover More

Stopping the Deletion of Cells

You can delete cells from a worksheet, and Excel will move the remaining cells either to the left or upwards. Deletions, ...

Discover More

Putting Cell Contents in Footers

Referencing information between cells in a worksheet is a piece of cake using some elemental formulas. You cannot, however, ...

Discover More

Program Successfully in Excel! John Walkenbach's name is synonymous with excellence in deciphering complex technical topics. With this comprehensive guide, "Mr. Spreadsheet" shows how to maximize your Excel experience using professional spreadsheet application development tips from his own personal bookshelf. Check out Excel 2013 Power Programming with VBA today!

MORE EXCELTIPS (MENU)

Wildcards in 'Replace With' Text

When doing searches in Excel, you can use wildcard characters in the specification of what you are searching. However, you ...

Discover More

Replacing Characters at the End of a Cell

The Find and Replace capabilities of Excel can come in handy, but they can't accomplish all your replacement needs. One such ...

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:

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 9 + 8?

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


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.

Links and Sharing
Share