Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default return error msg, not run time error


Dim oCell As Range

Set oCell = Cells.Find(What:="actualaxis1", _
After:=ActiveCell, _
LookIn:=xlFormulas, _
LookAt:=xlPart, _
SearchOrder:=xlByRows, _
SearchDirection:=xlNext, _
MatchCase:=False)
If Not oCell Is Nothing Then
'do your stuff
Else
Msgbox "Not found"
End If

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Bryan Kelly" wrote in message
om...
I need to write some macros and to do so I must understand some of the

Excel
functions. For example, when I record a macro to find something, I edit

the
macro and find this:

Cells.Find(What:="actualaxis1", After:=ActiveCell, LookIn:=xlFormulas,

_
LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False).Activate

Question: After running the macro, I opened the "Locals Window" and began
stepping through the macro to see what it does. I quickly received runtime
error 91: To make this short, that just means that my search object was

not
found. (Maybe, I and done a replace and the original search text was

indeed
missing. To throw a run time error when a search fails is just plain
absurd.
A not found condition should be an expected result, not a run time error.
What should I do to detect a not found condition and eliminate a run time
error?

(btw, when I try help, it tells me it cannot find VEENLR3.HLP. Its not

on
my Exel disk so I don't know how to resolve this but I supose that is

fodder
for another question.)

--
Bryan Kelly
Time is the medium we use to express out priorities.




--
Bryan Kelly
Time is the medium we use to express out priorities.




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
Visual Basic Error Run Time Error, Type Mismatch Meg Partridge Excel Discussion (Misc queries) 12 September 10th 08 06:10 PM
run-time error '91'-Close Button error ASCO IS Help Excel Discussion (Misc queries) 1 May 8th 06 04:25 PM
Run time error 1004, General ODBC error [email protected] New Users to Excel 0 September 19th 05 01:41 AM
VBA error - run-time error '1004': Romanian37 Excel Programming 3 May 21st 04 03:25 PM
Code Error - Run Time Error 5 (Disable Cut, Copy & Paste) Tim[_36_] Excel Programming 4 April 23rd 04 02:53 AM


All times are GMT +1. The time now is 09:09 AM.

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

About Us

"It's about Microsoft Excel"