How about
Public Function CountErr(cells As range) As Long
Dim cell As range
For Each cell In cells
If Application.WorksheetFunction.IsError(cell) Then CountErr = CountErr + 1
Next
End Function
Frage
I was trying to write an UDF in Excel VBA which would count errors (#NA!, #REF!...). I tried to translate Excel formulas into VBA language bud did not succed. Does somebody know a solution?
Thanks
Lösung
How about
Public Function CountErr(cells As range) As Long
Dim cell As range
For Each cell In cells
If Application.WorksheetFunction.IsError(cell) Then CountErr = CountErr + 1
Next
End Function