DEV Community

Andrews
Andrews

Posted on • Originally published at geekexcel.com on

How to Highlight All Errors Using Macros (VBA) In Excel Office 365?

If your worksheet has lots of error values, and you are tired of finding them? then continue reading this tutorial. Here, we come up with the easy steps to highlight all errors using Macros (VBA) in Excel Office 365. Let’s see them one-by-one.

Highlight All Errors using Macros:

To highlight all the errors in the worksheet, you need to follow the below steps.

  • In this image, you can see the example data from the range B1:B8 and there are some error values.
  • We are going to find them using macros.

Example data
Example data

  • On the Developer Tab, select the Visual Basic option under the Code section.

Select Visual Basic option
Select the Visual Basic option

  • Then you need to copy and paste the code given below.

VBA code to highlight errors using Macros

Sub HighlightAllErrors()

Dim cell As Range

For Each cell In ActiveSheet.UsedRange

If WorksheetFunction.IsError(cell) Then

cell.Style = “Bad”

End If

Next cell

End Sub

  • You need to save the code by selecting it. Then close the window.

Save the code
Save the code

  • You have to open the sheet containing the data. On the Developer Tab, choose the Macros option in the Code section.

Choose the Macros option
Choose the Macros option

  • You need to make sure that your macro is selected and click the Run button.

Click the Run button
Click the Run button

  • Finally, you will get the result as shown in the below image.

Output
Output

Verdict:

In this tutorial, we guided you to know the step-by-step instructions to highlight all errors using Macros (VBA) in Excel Office 365. Leave your queries/suggestions in the below comment section. Thanks for visiting Geek Excel. Keep Learning!

Keep Reading:

Top comments (0)