Skip to main content

Kutools for Office — One Suite. Five Tools. Get More Done.

How to hide specific error values in Excel?

Author Amanda Li Last modified

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.

A screenshot of specific error values being hidden


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.
A screenshot of the VBA code in the module window in Excel

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

Sub HideSpecificErrors_SelectedRange()
  '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
Notes:
  • 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 name 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.
A screenshot of the dialog box confirming that the specified error values were successfully hidden

5. The specified error values have been hidden at once.
A screenshot of specific error values being hidden


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

If you are not familiar with VBA code, the "Error Condition Wizard" feature of Kutools for Excel 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.

Kutools for Excel offers over 300 advanced features to streamline complex tasks, boosting creativity and efficiency. Itegarate with AI capabilities, Kutools automates tasks with precision, making data management effortless. Detailed information of Kutools for Excel...         Free trial...

1. On the "Kutools" tab, in the "Formula" group, click "More" > "Error Condition Wizard".
A screenshot of the Error Condition Wizard option on the Kutools tab in Excel

2. In the pop-up "Error Condition Wizard "dialog box, please do as follows:
  • In the "Range " box, click the range-selecting button to select the range that contains errors you want 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.
A
 screenshot of the Error Condition Wizard dialog box

3. Click "Ok". The specified error values are displayed as the option you selected.
A screenshot of the updated Excel sheet with error values replaced using Kutools' Error Condition Wizard

Kutools for Excel - Supercharge Excel with over 300 essential tools. Enjoy permanently free AI features! Get It Now


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
Other errors =ERROR.TYPE(123) #N/A

A screenshot of a list with values and errors

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)

A screenshot of the #DIV/0! error being replaced with 'Divide By Zero Error'

Notes:
  • 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.

Best Office Productivity Tools

🤖 Kutools AI Aide: Revolutionize data analysis based on: Intelligent Execution   |  Generate Code  |  Create Custom Formulas  |  Analyze Data and Generate Charts  |  Invoke Kutools Functions
Popular Features: Find, Highlight or Identify Duplicates   |  Delete Blank Rows   |  Combine Columns or Cells without Losing Data   |   Round without Formula ...
Super Lookup: Multiple Criteria VLookup    Multiple Value VLookup  |   VLookup Across Multiple Sheets   |   Fuzzy Lookup ....
Advanced Drop-down List: Quickly Create Drop Down List   |  Dependent Drop Down List   |  Multi-select Drop Down List ....
Column Manager: Add a Specific Number of Columns  |  Move Columns  |  Toggle Visibility Status of Hidden Columns  |  Compare Ranges & Columns ...
Featured Features: Grid Focus   |  Design View   |   Big Formula Bar    Workbook & Sheet Manager   |  Resource Library (Auto Text)   |  Date Picker   |  Combine Worksheets   |  Encrypt/Decrypt Cells    Send Emails by List   |  Super Filter   |   Special Filter (filter bold/italic/strikethrough...) ...
Top 15 Toolsets12 Text Tools (Add Text, Remove Characters, ...)   |   50+ Chart Types (Gantt Chart, ...)   |   40+ Practical Formulas (Calculate age based on birthday, ...)   |   19 Insertion Tools (Insert QR Code, Insert Picture from Path, ...)   |   12 Conversion Tools (Numbers to Words, Currency Conversion, ...)   |   7 Merge & Split Tools (Advanced Combine Rows, Split Cells, ...)   |   ... and more
Use Kutools in your preferred language – supports English, Spanish, German, French, Chinese, and 40+ others!

Supercharge Your Excel Skills with Kutools for Excel, and Experience Efficiency Like Never Before. Kutools for Excel Offers Over 300 Advanced Features to Boost Productivity and Save Time.  Click Here to Get The Feature You Need The Most...


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!

All Kutools add-ins. One installer

Kutools for Office suite bundles add-ins for Excel, Word, Outlook & PowerPoint plus Office Tab Pro, which is ideal for teams working across Office apps.

Excel Word Outlook Tabs PowerPoint
  • All-in-one suite — Excel, Word, Outlook & PowerPoint add-ins + Office Tab Pro
  • One installer, one license — set up in minutes (MSI-ready)
  • Works better together — streamlined productivity across Office apps
  • 30-day full-featured trial — no registration, no credit card
  • Best value — save vs buying individual add-in