View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
Tom Ogilvy Tom Ogilvy is offline
external usenet poster
 
Posts: 6,953
Default Using Find in VBA

Dim sh as worksheet, rng as range
for each sh in worksheets
sh.Activate
set rng = Cells.Find(What:="ERROR", After:= _
ActiveCell, LookIn:=xlValues)
if not rng is nothing then
msgbox "Error found at " & rng.Address(0,0,xlA1,True)
exit sub
end if
Next

--
Rgards,
Tom Ogilvy

"nir020" wrote:

I have written the following VBA which is used to find the text "ERROR"
within a worksheet:-

Cells.Find(What:="ERROR", After:= _
ActiveCell, LookIn:=xlValues).Activate

I would like to extend this Sub routine so that it search through the entire
workbook and if the text "ERROR" is found a message box is activated and the
sub broken.

Can anyone help?