Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Excel / Programming / January 2008

Tip: Looking for answers? Try searching our database.

Code to check errors in excel 2002

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Redan - 24 Jan 2008 11:06 GMT
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 !
Joel - 24 Jan 2008 12:23 GMT
MyError = WorksheetFunction.IsError(Range("A1"))

> 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 !
dbKemp - 24 Jan 2008 12:52 GMT
> 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
Dave Peterson - 24 Jan 2008 15:14 GMT
This checks to see what the formulas evaluate to:

Option Explicit
Sub testme()

   Dim TestRng As Range
   Dim wks As Worksheet
   
   Set wks = ActiveSheet
   With wks

       Set TestRng = Nothing
       On Error Resume Next
       Set TestRng = .Cells.SpecialCells(xlCellTypeFormulas, xlErrors)
       On Error GoTo 0
       
       If TestRng Is Nothing Then
           MsgBox "No errors in formulas!"
       Else
           MsgBox "You've got errors here: " & TestRng.Address(external:=True)
       End If
   End With
       
End Sub

> 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 !

Signature

Dave Peterson

Redan - 25 Jan 2008 13:15 GMT
Thanks Dave!!!
> This checks to see what the formulas evaluate to:
>
[quoted text clipped - 28 lines]
>>
>> Thank you in advance !
Redan - 28 Jan 2008 16:33 GMT
Hello Dave,

the code doesn't list #REF errors!
> This checks to see what the formulas evaluate to:
>
[quoted text clipped - 28 lines]
>>
>> Thank you in advance !
Dave Peterson - 28 Jan 2008 17:37 GMT
I started a test worksheet.

I put =A1 in C9

I deleted column A and ran the code and it showed the error.

Maybe you could be more specific.

> Hello Dave,
>
[quoted text clipped - 35 lines]
> >
> > Dave Peterson

Signature

Dave Peterson

 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.