user3721539
user3721539

Reputation: 11

Runtime error 1004

I have used the following (simplest) vb code so many times in the same sheet and it always worked but for some reason it now gives me a runtime error

Sub Home()
    Application.Goto reference:=Worksheets("Home").Range("a5"), Scroll:=True
End Sub

Upvotes: 1

Views: 1340

Answers (1)

Patrick Hofman
Patrick Hofman

Reputation: 156978

This error message seems to mean that the worksheet name Home does not exist.

Check whether the sheet name is exactly Home, and that you didn't change it by accident.

I can reproduce this error message when I use this code (thus giving an invalid range):

 Application.Goto reference:=Worksheets("Home"), Scroll:=True

Run-time error 1004: Method 'Goto' of object '_Application' failed

And, as L42 mentioned, I also reproduced that this method will fail when the worksheet is hidden.

Upvotes: 3

Related Questions