How to count number of errors?

  • Thread starter Thread starter Faraz A. Qureshi
  • Start date Start date
F

Faraz A. Qureshi

In simple words what type of a code would be required for:
....
On Error
Counter=Counter+1;
Resume Next Or Goto 0
....

In the end:

Msgbox "Number of errors were " & Counter
 
Sub test()

Dim a As Integer
Set c = Nothing
ErrorCount = 0
On Error GoTo 100
a = c

MsgBox "Number of errors were " & ErrorCount
Exit Sub

100:
ErrorCount = ErrorCount + 1
Resume Next


End Sub
 
Resume Next is probably what you are looking for, but there is a caution
that come with it. If your subsequent code depends on the correctly
calculated values that are erroring out above them, then you may end up
producing additional errors that would not normally occur had the previous
error not taken place which, of course, would give you a false count.
 
Would you please clarify with an example like finding how many of cells in
A1:A10 do not reflect the names of sheets present in a workbook?

Best Regards,

Faraz
 
I'm getting the feeling your use of the phrase "In simple words" in your
first posting was, perhaps, too simple a statement. VB's On Error statement
is used for responding to errors generated by your code, not errors on your
worksheet. I think it might be a good idea if you explain in some detail
exactly what your worksheet's set up is and what you are trying to do with
it.
 
Back
Top