check entire workbook for errors

daveyc18

Well-known Member
Joined
Feb 11, 2013
Messages
708
Office Version
  1. 365
  2. 2010
looking for code to check for errors (n/a , ref# etc ) in the entire workbook then if it finds any ...write the sheet name in column A, cell address (eg a1) in column. B in a worksheet called "errors"
 

Excel Facts

Did you know Excel offers Filter by Selection?
Add the AutoFilter icon to the Quick Access Toolbar. Select a cell containing Apple, click AutoFilter, and you will get all rows with Apple
try trhis code:
VBA Code:
Sub test()
indi = 2
For i = 1 To Worksheets.Count
 If Worksheets(i).Name <> "errors" Then
  With Worksheets(i)
    nm = .Name
    Lc = .Cells.Find(What:="*", LookIn:=xlFormulas, SearchOrder:=xlByColumns, SearchDirection:=xlPrevious).Column + 1
    lr = .Cells.Find(What:="*", LookIn:=xlFormulas, SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row
    inarr = .Range(.Cells(1, 1), .Cells(lr, Lc))
  End With
   For j = 1 To lr
    For k = 1 To Lc
      If IsError(inarr(j, k)) Then
       With Worksheets("errors")
        Addr = .Range(.Cells(j, k), .Cells(j, k)).Address
        .Range(.Cells(indi, 1), .Cells(indi, 1)) = nm
        .Range(.Cells(indi, 2), .Cells(indi, 2)) = Addr
        indi = indi + 1
       End With
      End If
    Next k
   Next j
 End If
Next i

End Sub
 
Upvote 0
try trhis code:
VBA Code:
Sub test()
indi = 2
For i = 1 To Worksheets.Count
 If Worksheets(i).Name <> "errors" Then
  With Worksheets(i)
    nm = .Name
 [B]   Lc = .Cells.Find(What:="*", LookIn:=xlFormulas, SearchOrder:=xlByColumns, SearchDirection:=xlPrevious).Column + 1[/B]
    lr = .Cells.Find(What:="*", LookIn:=xlFormulas, SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row
    inarr = .Range(.Cells(1, 1), .Cells(lr, Lc))
  End With
   For j = 1 To lr
    For k = 1 To Lc
      If IsError(inarr(j, k)) Then
       With Worksheets("errors")
        Addr = .Range(.Cells(j, k), .Cells(j, k)).Address
        .Range(.Cells(indi, 1), .Cells(indi, 1)) = nm
        .Range(.Cells(indi, 2), .Cells(indi, 2)) = Addr
        indi = indi + 1
       End With
      End If
    Next k
   Next j
 End If
Next i

End Sub

tks!

it works, but eventually it sets object variable or with variable not set after all the errors are found
 
Upvote 0
i think i got it...tks for your help...helped me

Code:
indic = 2
Dim ws As Worksheet, r As Range

For Each ws In Worksheets
    For Each r In ws.UsedRange
        If IsError(r.Value) Then
        
        
        
         Sheets("errors").Range("a" & indic) = r.Parent.Name
        Sheets("errors").Range("b" & indic) = r.Address
        
       indic = indic + 1
       
     
        End If
    Next
Next
 
Upvote 0

Forum statistics

Threads
1,215,335
Messages
6,124,327
Members
449,155
Latest member
ravioli44

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top