How to quickly find formula errors in workbook using vba?

cjindenver

New Member
Joined
Jun 3, 2014
Messages
4
I have about 100 reports that I have to run every day, and they are automated using excel macros. There are a few that are extremely visible to decision makers in my company, and I want to find a way to quickly search the entire report for broken or errored formulas or cell values (#REF, #DIV/0!, etc.) before sending out the report. Some of the files are 10-18 MB, and I am trying to find the most efficient way to find any such errors. I could loop through every cell in the used range of each sheet of each report, but that would take forever. Is there a better way to accomplish this task in VBA that I have somehow been missing? I'm picturing a function that can be used to determine if there are errors anywhere in the report, and then I could use the result (true/false) to send an error notice email. Thanks in advance!
 

Excel Facts

Which lookup functions find a value equal or greater than the lookup value?
MATCH uses -1 to find larger value (lookup table must be sorted ZA). XLOOKUP uses 1 to find values greater and does not need to be sorted.
Hi & welcome to MrExcel.
Maybe something like
Code:
Sub cjindenver()
   Dim Ws As Worksheet
   Dim Chk As Range
   
   For Each Ws In Worksheets
      On Error Resume Next
      Set Chk = Ws.UsedRange.SpecialCells(xlFormulas, xlErrors)
      On Error GoTo 0
      If Not Chk Is Nothing Then MsgBox "errors on " & Ws.Name
      Set Chk = Nothing
   Next Ws
End Sub
 
Upvote 0
Hi & welcome to MrExcel.
Maybe something like
Code:
Sub cjindenver()
   Dim Ws As Worksheet
   Dim Chk As Range
   
   For Each Ws In Worksheets
      On Error Resume Next
      Set Chk = Ws.UsedRange.SpecialCells(xlFormulas, xlErrors)
      On Error GoTo 0
      If Not Chk Is Nothing Then MsgBox "errors on " & Ws.Name
      Set Chk = Nothing
   Next Ws
End Sub


That seems to be doing what I want, and I think I can tweak this a bit to do exactly what I'm looking for. Thanks!
 
Upvote 0
You're welcome & thanks for the feedback
 
Upvote 0

Forum statistics

Threads
1,216,377
Messages
6,130,261
Members
449,568
Latest member
mwl_y

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top