Thread: Error Search
View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
OssieMac OssieMac is offline
external usenet poster
 
Posts: 2,510
Default Error Search

Hi Cyberwolf,

Hope this helps.

Sub Find_Error()
Dim wks As Worksheet 'Each worksheet in workbook
Dim rngToSearch As Range
Dim rngFound As Range
Dim strFirstAddress As String
Dim strToFind

strToFind = "#N/A"
For Each wks In Worksheets
Set rngToSearch = wks.Cells

Set rngFound = rngToSearch.Find(What:=strToFind, _
LookIn:=xlValues, _
LookAt:=xlWhole, _
SearchOrder:=xlByRows, _
SearchDirection:=xlNext, _
MatchCase:=False, _
SearchFormat:=False)

If Not rngFound Is Nothing Then
strFirstAddress = rngFound.Address
Do
'Put your code here to handle the error
rngFound.Interior.ColorIndex = 6

Set rngFound = rngToSearch.FindNext(rngFound)
Loop Until rngFound.Address = strFirstAddress
End If

Next wks

End Sub

Regards,

OssieMac