View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
Héctor Miguel Héctor Miguel is offline
external usenet poster
 
Posts: 434
Default Sub to check and report any formula returned error (eg: #REF!)

hi, Max !

How could the sub be tweaked a little to write the results of the checks into a new sheet? (instead of the msgbox)


this could be one way...

Sub ChkErr()
Dim ws As Worksheet, Tmp As String, Msg As String, n As Byte, TmpArray
For Each ws In Worksheets
On Error Resume Next
Tmp = ws.Cells.SpecialCells(xlCellTypeFormulas, xlErrors).Address(0, 0)
If Err = 0 Then Msg = Msg & ";" & ws.CodeName & ": " & Tmp
Next
If Msg < "" Then
TmpArray = Split(Mid(Msg, 2), ";")
Application.ScreenUpdating = False
Worksheets.Add After:=Worksheets(Worksheets.Count)
[a1] = "Errors found on sheet(s)..."
For n = LBound(TmpArray) To UBound(TmpArray)
[a2].Offset(n).Value = TmpArray(n)
Next
Else
MsgBox "No errors found !"
End If
End Sub

hth,
hector.