Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 31
Default Using Find in VBA

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?
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 857
Default Using Find in VBA

maybe something like this:

Sub test()
Dim sht As Worksheet
Dim c As Range

For Each sht In Worksheets
Set c = sht.Cells.Find(What:="ERROR")
If Not c Is Nothing Then
sht.Activate
c.Activate
MsgBox "ERROR FOUND!"
Exit Sub
End If
Next sht
MsgBox "NO ERRORS FOUND"

End Sub


--
Hope that helps.

Vergel Adriano


"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?

  #3   Report Post  
Posted to microsoft.public.excel.programming
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?

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Find and Replace - delete the remainder of the text in the cell after my Find [email protected] Excel Programming 4 August 4th 07 03:39 AM
Find First Non blank cell than find column header and return that value Silver Rose Excel Worksheet Functions 10 April 30th 07 05:56 PM
Despite data existing in Excel 2002 spreadsheet Find doesn't find AnnieB Excel Discussion (Misc queries) 1 June 16th 06 02:15 AM
find and delete duplicate entries in two columns or find and prin. campare 2 columns of numbers-find unique Excel Programming 1 November 24th 04 04:09 PM
find and delete text, find a 10-digit number and put it in a textbox Paul Excel Programming 3 November 16th 04 04:21 PM


All times are GMT +1. The time now is 12:28 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"