View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Tom Ogilvy Tom Ogilvy is offline
external usenet poster
 
Posts: 27,285
Default Find Method doesn't work

I suspect you have a construct like

cells.Find("target").Select

if the target is not found, cells.find resolves to nothing so you have

nothing.Select
which raises that error. You should do

set rng = cells.find("target")
if not rng is nothing then
rng.select
Else
msgbox "Target not found"
End if

Regards,
Tom Ogilvy


"Slugo" wrote in message
...
I have a function that uses the find method to search for
a string within a spreadsheet. It works fine when called,
except when I call it from a For loop I get a RunTime erro
91: Object variable or with block variable not set.

Does anybody know why I keep getting this?