View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Tom Ogilvy Tom Ogilvy is offline
external usenet poster
 
Posts: 27,285
Default run time error 91 all of a sudden

You will get this error if the item you are searching for is not found.

Sub gotoselection()
Dim rng as Range
set rng = Cells.Find(InputBox("Enter number to find"))
If not rng is nothing then
Application.Goto reference:=rng.Offset(, -2)
Else
msgbox "Item not found"
End if
End Sub

--
Regards,
Tom Ogilvy


"Todd" wrote in message
...
Run time error 91 just started popping up on a macro that
you all helped me with months ago.

erro 91 says object variable or With block variable not set

The Marco is:

Sub gotoselection()
x = Cells.Find(InputBox("Enter number to find")).Address
Application.Goto reference:=Range(x).Offset(, -2)
End Sub

I occasionaly change the -2 to a different number but it
always worked.

whats going on?

I am in column c right now and need to jump 2 spaces to
left so should be -2 like have been doing