function - Run time error 91-Object variable or With block variable not set -


run-time error '91':  object variable or block variable not set  sub findfilmnameusingeventhandler()  sheet1.activate  dim searchrange range dim filmname string dim releasedate integer dim filmtofind string  set searchrange = range("b3", range("b2").end(xldown)) filmname = inputbox("type movie") filmtofind = searchrange.find(what:=filmname)  'filmtofind = range("b2:b15").find(what:=filmname)  msgbox filmtofind & "  movie "  end sub` 

hi, thank reviewing question. i've declared range variable & use search string "filmtofind = searchrange.find(what:=filmname)" & fails run time error run-time error '91': object variable or block variable not set can search same range declared range filmtofind = range("b2:b15").find(what:=filmname) & can find variable. please point mistake?

the film entering not exist in list, try error check this:

sub something()  dim searchrange range dim filmname string dim releasedate integer dim filmtofind string  set searchrange = range("b3", range("b2").end(xldown)) filmname = inputbox("type movie") if worksheetfunction.countif(searchrange, filmname) > 0     filmtofind = searchrange.find(what:=filmname) else     filmtofind = "film not found!" end if  'filmtofind = range("b2:b15").find(what:=filmname)  msgbox filmtofind & "  movie "  end sub 

Comments

Popular posts from this blog

apache - PHP Soap issue while content length is larger -

asynchronous - Python asyncio task got bad yield -

javascript - Complete OpenIDConnect auth when requesting via Ajax -