Note: The other languages of the website are Google-translated. Back to English
English English

How to hide specific error values in Excel?

Let’s say there are error values in your Excel worksheet that you don't need to correct but to hide. To address the problem, we’ve talked about how to hide all error values in Excel, now, what if you want to only hide specific error values? In this tutorial, we will show you how to get this job done in three ways below.


Hide multiple specific error values by turning the text white with VBA

We have created two VBA codes to help you hide multiple specific error values in the selected range or across multiple worksheets quickly by turning the font color of the specified errors white. Please follow the steps below and run the code according to your needs.

1. In your Excel, press the Alt + F11 keys to open the Microsoft Visual Basic for Applications window.

2. Click Insert > Module. Then copy either of the following VBA codes to the Module window.

VBA code 1: Hide multiple specific error values in the selected range

'Updated by ExtendOffice 20220824
Dim xRg As Range
Dim xFindStr As String
Dim xFindRg As Range
Dim xARg As Range
Dim xURg As Range
Dim xFindRgs As Range
Dim xFAddress As String
Dim xBol As Boolean
Dim xJ

xArrFinStr = Array("#DIV/0!”, “#N/A”, “#NAME?") 'Enter the errors to hide, enclose each with double quotes and separate them with commas

On Error Resume Next
Set xRg = Application.InputBox("Please select the range that includes the errors to hide:", "Kutools for Excel", , Type:=8)
If xRg Is Nothing Then Exit Sub

xBol = False
For Each xARg In xRg.Areas
    Set xFindRg = Nothing
    Set xFindRgs = Nothing
    Set xURg = Application.Intersect(xARg, xARg.Worksheet.UsedRange)
    For Each xFindRg In xURg
        For xJ = LBound(xArrFinStr) To UBound(xArrFinStr)
            If xFindRg.Text = xArrFinStr(xJ) Then
                xBol = True
                If xFindRgs Is Nothing Then
                    Set xFindRgs = xFindRg
                Else
                    Set xFindRgs = Application.Union(xFindRgs, xFindRg)
                End If
            End If
        Next
    Next
    If Not xFindRgs Is Nothing Then
        xFindRgs.Font.ThemeColor = xlThemeColorDark1
        
    End If
Next
If xBol Then
    MsgBox "Successfully hidden."
Else
     MsgBox "No specified errors were found."
End If
End Sub

Note: In the snippet xArrFinStr = Array("#DIV/0!”, “#N/A”, “#NAME?") in the 12th row, you should replace "#DIV/0!”, “#N/A”, “#NAME?" with the actual errors you want to hide, remember to enclose each value with double quotes and separate them with commas.

VBA code 2: Hide multiple specific error values across multiple sheets

Sub HideSpecificErrors_WorkSheets()
'Updated by ExtendOffice 20220824
Dim xRg As Range
Dim xFindStr As String
Dim xFindRg As Range
Dim xARg, xFindRgs As Range
Dim xWShs As Worksheets
Dim xWSh As Worksheet
Dim xWb As Workbook
Dim xURg As Range
Dim xFAddress As String
Dim xArr, xArrFinStr
Dim xI, xJ
Dim xBol As Boolean
xArr = Array("Sheet1", "Sheet2") 'Names of the sheets where to find and hide the errors. Enclose each with double quotes and separate them with commas
xArrFinStr = Array("#DIV/0!", "#N/A", "#NAME?") 'Enter the errors to hide, enclose each with double quotes and separate them with commas
'On Error Resume Next
Set xWb = Application.ActiveWorkbook
xBol = False
For xI = LBound(xArr) To UBound(xArr)
    Set xWSh = xWb.Worksheets(xArr(xI))
    Set xFindRg = Nothing
    xWSh.Activate
    Set xFindRgs = Nothing

    Set xURg = xWSh.UsedRange
    Set xFindRgs = Nothing
    For Each xFindRg In xURg
        For xJ = LBound(xArrFinStr) To UBound(xArrFinStr)
            If xFindRg.Text = xArrFinStr(xJ) Then
                xBol = True
                If xFindRgs Is Nothing Then
                    Set xFindRgs = xFindRg
                Else
                    Set xFindRgs = Application.Union(xFindRgs, xFindRg)
                End If
            End If
        Next
    Next
    If Not xFindRgs Is Nothing Then
        xFindRgs.Font.ThemeColor = xlThemeColorDark1
        
    End If
Next
If xBol Then
    MsgBox "Successfully hidden."
Else
     MsgBox "No specified errors were found."
End If
End Sub
Note:
  • In the snippet xArr = Array("Sheet1", "Sheet2") in the 15th row, you should replace "Sheet1", "Sheet2" with the actual names of the sheets where you want to hide the errors. Remember to enclose each sheet names with double quotes and separate them with commas.
  • In the snippet xArrFinStr = Array("#DIV/0!”, “#N/A”, “#NAME?") in the 16th row, you should replace "#DIV/0!”, “#N/A”, “#NAME?" with the actual error you want to hide, remember to enclose each error with double quotes and separate them with commas.

3. Press F5 to run the VBA code. Note: If you used the VBA code 1, a dialog box will pop up asking you to select the range where to find and delete error values. You can also click on a sheet tab to select the whole sheet.

4. The dialog box as shown below pops up telling you that the specified error values were hidden. Click OK to close the dialog.

5. The specified error values have been hidden at once.


Replace specific error values with other values with Error Condition Wizard feature

If you are not familiar with VBA code, Kutools for Excel’s Error Condition Wizard feature could help you easily find all the error values, all #N/A errors, or any errors except #N/A, and replace them with other values you specify, please read on to find out how to get this job done.

1. On the Kutools tab, in the Formula group, click More > Error Condition Wizard.

2. In the pop-up Error Condition Wizard dialog box, please do as follows:
  • In the Range box, click the range-selecting button at right to specify the range that contains errors to hide. Note: To search across the whole sheet, click on the sheet tab.
  • In the Error types section, specify what error values to hide.
  • In the Error display section, pick a way how do you want to replace the errors with.

3. Click Ok. The specified error values are displayed as the option you selected.

Note: To use the Error Condition Wizard feature, you should have Kutools for Excel installed in your computer. If you do not have Kutools installed, click here to download and install. The professional Excel add-in offers a 30-day free trial with no limitations.


Replace a specific error with other values with a formula

To replace a specific error value, Excel’s IF, IFNA, and ERROR.TYPE functions can do you a favor. But first, you should know each error value’s corresponding number code.

# Error Formula Returns
#NULL! =ERROR.TYPE(#NULL!) 1
#DIV/0! =ERROR.TYPE(#DIV/0!) 2
#VALUE! =ERROR.TYPE(#VALUE!) 3
#REF! =ERROR.TYPE(#REF!) 4
#NAME? =ERROR.TYPE(#NAME?) 5
#NUM! =ERROR.TYPE(#NUM!) 6
#N/A =ERROR.TYPE(#N/A) 7
#GETTING_DATA =ERROR.TYPE(#GETTING_DATA) 8
#SPILL! =ERROR.TYPE(#SPILL!) 9
#UNKNOWN! =ERROR.TYPE(#UNKNOWN!) 12
#FIELD! =ERROR.TYPE(#FIELD!) 13
#CALC! =ERROR.TYPE(#CALC!) 14
Anything else =ERROR.TYPE(123) #N/A

For example, you have a table with values as shown above. To replace the #DIV/0! error with the text string Divide By Zero Error, you should first find the code of this error, which is 2. And then apply the following formula in the cell B2, and drag the fill handle down to apply the formula to below cells:

=IF(IFNA(ERROR.TYPE(A2),A2)=2,"Divide By Zero Error",A2)

Note:
  • In the formula, you can replace the error code 2 to the code corresponding to other error value.
  • In the formula, you can replace the text string "Divide By Zero Error" to other text message, or "" if you want to replace the error with a blank cell.

Related articles

How To Hide All Error Values In Excel?

When you work on Excel worksheet, sometimes, you may find there are some errors values, such as #DIV/0, #REF, #N/A and so on, they are caused by the formulas error. Now, you would like to hide all these error values in the worksheet, how could you solve this task quickly and easily in Excel?

How To Change #DIV/0! Error To The Readable Message In Excel?

Sometimes, when we use the formula to calculate in excel, some error messages will display. For example, in this formula =A1/B1, if B1 is empty or contains 0, the formula will display a #DIV/0 error. Is there any way to make those error messages clearly readable or if you want to use other messages to replace the errors, what should you do?

How To Avoid #Ref Error While Deleting The Rows In Excel?

While you refer a cell to another cell, the cell will display #REF error if the reference row has been deleted as below screenshot shown. Now I will talk about how to avoid #ref error and automatically refer to next cell while deleting the row.

How To Highlight All Error Cells In Excel?

If you create formulas in your worksheet, it will be inevitable to appear some error values. Can you highlight all these cells which contain the error values in your worksheet at once? The Conditional Formatting utility in Excel can help you solve this problem.


The Best Office Productivity Tools

Kutools for Excel Solves Most of Your Problems, and Increases Your Productivity by 80%

  • Reuse: Quickly insert complex formulas, charts and anything that you have used before; Encrypt Cells with password; Create Mailing List and send emails...
  • Super Formula Bar (easily edit multiple lines of text and formula); Reading Layout (easily read and edit large numbers of cells); Paste to Filtered Range...
  • Merge Cells/Rows/Columns without losing Data; Split Cells Content; Combine Duplicate Rows/Columns... Prevent Duplicate Cells; Compare Ranges...
  • Select Duplicate or Unique Rows; Select Blank Rows (all cells are empty); Super Find and Fuzzy Find in Many Workbooks; Random Select...
  • Exact Copy Multiple Cells without changing formula reference; Auto Create References to Multiple Sheets; Insert Bullets, Check Boxes and more...
  • Extract Text, Add Text, Remove by Position, Remove Space; Create and Print Paging Subtotals; Convert Between Cells Content and Comments...
  • Super Filter (save and apply filter schemes to other sheets); Advanced Sort by month/week/day, frequency and more; Special Filter by bold, italic...
  • Combine Workbooks and WorkSheets; Merge Tables based on key columns; Split Data into Multiple Sheets; Batch Convert xls, xlsx and PDF...
  • More than 300 powerful features. Supports Office/Excel 2007-2019 and 365. Supports all languages. Easy deploying in your enterprise or organization. Full features 30-day free trial. 60-day money back guarantee.
kte tab 201905

Office Tab Brings Tabbed interface to Office, and Make Your Work Much Easier

  • Enable tabbed editing and reading in Word, Excel, PowerPoint, Publisher, Access, Visio and Project.
  • Open and create multiple documents in new tabs of the same window, rather than in new windows.
  • Increases your productivity by 50%, and reduces hundreds of mouse clicks for you every day!
officetab bottom
Comments (0)
No ratings yet. Be the first to rate!
There are no comments posted here yet
Leave your comments
Posting as Guest
×
Rate this post:
0   Characters
Suggested Locations