ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   How to count number of errors? (https://www.excelbanter.com/excel-programming/431790-how-count-number-errors.html)

Faraz A. Qureshi

How to count number of errors?
 
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

--
Best Regards,

Faraz

joel

How to count number of errors?
 
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


"Faraz A. Qureshi" wrote:

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

--
Best Regards,

Faraz


Rick Rothstein

How to count number of errors?
 
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.

--
Rick (MVP - Excel)


"Faraz A. Qureshi" wrote in
message ...
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

--
Best Regards,

Faraz



Faraz A. Qureshi

How to count number of errors?
 
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


"Joel" wrote:

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


"Faraz A. Qureshi" wrote:

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

--
Best Regards,

Faraz


Rick Rothstein

How to count number of errors?
 
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.

--
Rick (MVP - Excel)


"Faraz A. Qureshi" wrote in
message ...
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


"Joel" wrote:

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


"Faraz A. Qureshi" wrote:

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

--
Best Regards,

Faraz




All times are GMT +1. The time now is 04:42 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com