Code Error

agonysWeeper

Board Regular
Joined
Feb 4, 2011
Messages
146
Private Sub Workbook_Open()
Application.Goto Reference:=Sheet3.Range("A1"), Scroll:=True
End Sub


I have this code in my Workbook so that everytime I open this excel file with 36 sheet, it will always open focus to Sheet3, but in opening this file the macro debugger always appear for some error which is highlighted in red.

Anyone can fixed this problem?
Appreciate reply.
Thanks
 

Excel Facts

Can you AutoAverage in Excel?
There is a drop-down next to the AutoSum symbol. Open the drop-down to choose AVERAGE, COUNT, MAX, or MIN
That works for me. Are you sure that you have a sheet with the codename Sheet3?
 
Upvote 0
Try Worksheets("Sheet3") instead of just Sheet3.
 
Upvote 0
Yes Mr. Vog. I am pretty sure.
2gx41ms.jpg
 
Upvote 0
Does this work?

Code:
Private Sub Workbook_Open()
Application.Goto Reference:=Sheets(3).Range("A1"), Scroll:=True
End Sub
 
Upvote 0
Got the error, I protect the sheet3 thats why there is an error.
Any solution to avoid this error even the sheet3 protected?
 
Upvote 0
Try like this

Code:
Private Sub Workbook_Open()
With Sheet3
    .Unprotect password:="abc"
    Application.Goto Reference:=.Range("A1"), Scroll:=True
    .Protect password:="abc"
End With
End Sub
 
Upvote 0
Make sure A1 on this sheet is UnLocked and that when you apply protection you allow selection of Unlocked cells (or just allow selection of Locked cells, but you may not want to do this).
 
Upvote 0
All my sheets is all protected.

anyway, this code is running.
Thanks :)
Try like this

Code:
Private Sub Workbook_Open()
With Sheet3
    .Unprotect password:="abc"
    Application.Goto Reference:=.Range("A1"), Scroll:=True
    .Protect password:="abc"
End With
End Sub
 
Upvote 0

Forum statistics

Threads
1,224,595
Messages
6,179,798
Members
452,943
Latest member
Newbie4296

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top