View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Barb Reinhardt Barb Reinhardt is offline
external usenet poster
 
Posts: 3,355
Default Macro to find and log all formula errors on all sheets

Try this

Sub Test()
Dim aWB As Workbook
Dim myWB As Workbook
Dim r As Range

Set aWB = ActiveWorkbook
Set myWB = Workbooks.Add
Set myWS = myWB.Worksheets(1)
myWS.Name = "Errors Found"
lrow = 1
myWS.Cells(1, 1) = "Workbook Name"
myWS.Cells(1, 2) = "Worksheet Name"
myWS.Cells(1, 3) = "Cell Address"
myWS.Cells(1, 4) = "Cell Value"
myWS.Cells(1, 5) = "Cell Formula"

For Each WS In aWB.Worksheets
For Each r In WS.UsedRange
If IsError(r) Then
lrow = lrow + 1
myWS.Cells(lrow, 1) = aWB.Name
myWS.Cells(lrow, 2) = WS.Name
myWS.Cells(lrow, 3) = r.Address
myWS.Cells(lrow, 4) = r.Value
myWS.Cells(lrow, 5) = "'" & r.FormulaR1C1
End If
Next r
Next WS

End Sub
--
HTH,
Barb Reinhardt



"Adnan" wrote:

Is there a code that goes thru each sheet of the work book and looks for
formula errors (any type) and then record the name of the file and type of
error into a different workbook?

I have a workbook that has a list of paths to lots of other workbooks, in
this workbook I want to create a macro that open each and everyone of those
workbooks listed and look for any type of formula errors (i.e.: #VALUE or
#DIV/O, or #N/A etc€¦) in them.

Your help is greatly appreciated,
Adnan