LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Using Find statement in VBA module causes error 91

Dim rng as Range
Application.FindFormat.Clear
set rng = ThisWorkbook.Worksheets(reference_sheet).Cells.Fin d( _
What:=searched_for_instrument_value, _
After:= ActiveCell, _
LookIn:=xlFormulas, _
LookAt:=xlPart,
SearchOrder:=xlByColumns, _
SearchDirection:=xlNext, _
MatchCase:=False, )
SearchFormat:=False)

If not rng is nothing then
rng.Select
else
msgbox searched_for_instrument_value & " was not found"
End if

--
Regards,
Tom Ogilvy


"Gsp" wrote in message
...
Have written the following VBA code which appears fine to me:

Application.FindFormat.Clear

ThisWorkbook.Worksheets(reference_sheet).Cells.Fin d(What:=searched_for_instr
ument_value, After:= _
ActiveCell, LookIn:=xlFormulas, LookAt:=xlPart,
SearchOrder:=xlByColumns, SearchDirection:= _
xlNext, MatchCase:=False, SearchFormat:=False).Activate

(where reference_sheet and searched_for_instrument_value are parameters
passed to the procedure in which this code resides)
However, the following error is generated every time I run this code:
"Object variable or With block variable not set (Error 91)"
Both parameters passed down to the procedure have valid values in them.

Have tried recording myself using the Find function but the code it

produces
is almost identical (except for the variables being used to refer to the
worksheet to llok in & what to look for). Can anybody help me, or point

me
in the right direction (e.g. are there common causes for this error other
than those listed in the Help)?

Thanks.



 
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
Excel: Compilation error in Module 1. How can I find it? Tom Torda Excel Discussion (Misc queries) 1 January 13th 07 11:51 PM
if statement module use please help andrewm Excel Worksheet Functions 4 May 29th 05 12:54 PM
error "module not found" Amit Excel Discussion (Misc queries) 1 May 13th 05 01:24 PM
How do I get rid of "Compile error in hidden module" error message David Excel Discussion (Misc queries) 4 January 21st 05 11:39 PM
Compile error in hidden module error Melissa Zebrowski Excel Programming 3 February 20th 04 01:29 PM


All times are GMT +1. The time now is 03:01 PM.

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"