View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
dbKemp dbKemp is offline
external usenet poster
 
Posts: 58
Default Code to check errors in excel 2002

On Jan 24, 6:06 am, "Redan" wrote:
Hello,

Does anyone have a vba code that checks if all the formulas inside a
worksheet does not contain any errors such as #REF, etc ... ?

Thank you in advance !


Public Function WorksheetErrors(ByRef Target As Range) As Boolean
Dim rCell As Range
Dim vErrorArray As Variant
Dim iCounter As Integer

vErrorArray = Array("#N/A", "#DIV/0!", "#NAME?", "#NULL!", "#NUM!",
"#REF!", "#VALUE!")
Application.EnableEvents = False
For iCounter = 0 To UBound(vErrorArray)
With Target
Set rCell = .Find(vErrorArray(iCounter), LookIn:=xlValues,
lookat:=xlWhole)
If Not rCell Is Nothing Then
WorksheetErrors = True
Exit For
End If
End With
Next

Set rCell = Nothing
End Function