run time error 91 all of a sudden

T

Todd

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
 
T

Tom Ogilvy

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
 
T

todd

turns out there is some goofy formatting issue - if the
cell contains 05007 and you type o5007 it returns the not
found but if you type 5007 it goes to the cell

thanks for the time todd
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top