Open Specific Sheet while file open

Senthil Murugan

New Member
Joined
Sep 25, 2024
Messages
48
Office Version
  1. 365
Platform
  1. Windows
Good Morning everybody



I have 5 sheets named Sheet1 to Sheet5 WITH “ all sheets Password Protected”



Before closing the file

I have set all the sheets “ visible = false” EXCEPT Sheet1



What I need is

When I open the file ( workbook ) , the Sheet1 shall be activated irrespective of

  • last activated and saved sheet
  • last activated and unsaved sheet and unsaved workbook ( without saving workbook)
Situation

I am activating the Sheet4 ( for example ) but typing something and UNSAVED the sheet4 and UNSAVED the workbook when closing the file

My problem is

When I open the file, it goes to Sheet4 instead of sheet1



My code in ThisWorkbook ( Open) is



Sheets("Sheet1").Activate

Sheets("Sheet1").Select

Sheets("Sheet1").Unprotect Password:="123"

Sheets(“Sheet1”).Range(“A1”).Select

Sheets("Sheet1").Protect Password:="123"







Any solution to this will be highly solicited



Thanks in advance
 

Excel Facts

When they said...
When they said you are going to "Excel at life", they meant you "will be doing Excel your whole life".
Kind Attention Mr.Fuji

Could you please advise to get solutions to my question?

With regards


A.Senthil Murugan
 
Upvote 0
I'm not sure if I understood correctly, but try:
VBA Code:
Private Sub Workbook_Open()
    With Sheets("Sheet1")
        .Activate
        .Unprotect "123"
        .Range("A1").Select
        .Protect "123"
    End With
End Sub
 
Upvote 0
Or more to the point ?

VBA Code:
Option Explicit

Private Sub Workbook_Open()

    Sheets("Sheet1").Activate
      
    Sheets("Sheet1").Range("A1").Select

End Sub

Your code needs to be pasted into the ThisWorkbook module.
 
Upvote 0
I'm not sure if I understood correctly, but try:
VBA Code:
Private Sub Workbook_Open()
    With Sheets("Sheet1")
        .Activate
        .Unprotect "123"
        .Range("A1").Select
        .Protect "123"
    End With
End Sub
This does not give my desired result but i think saving the file is the only way. Anyway thanks for your reply
 
Upvote 0
Or more to the point ?

VBA Code:
Option Explicit

Private Sub Workbook_Open()

    Sheets("Sheet1").Activate
     
    Sheets("Sheet1").Range("A1").Select

End Sub

Your code needs to be pasted into the ThisWorkbook module.
This does not give my desired result . Anyway thanks for your reply
 
Upvote 0
I've included the use of the password :

VBA Code:
Option Explicit

Private Sub Workbook_Open()

    Sheets("Sheet1").Activate
   
    Sheets("Sheet1").Unprotect Password:="123"
      
    Sheets("Sheet1").Range("A1").Select

    Sheets("Sheet1").Protect Password:="123"

End Sub
 
Upvote 0
I've included the use of the password :

VBA Code:
Option Explicit

Private Sub Workbook_Open()

    Sheets("Sheet1").Activate
  
    Sheets("Sheet1").Unprotect Password:="123"
     
    Sheets("Sheet1").Range("A1").Select

    Sheets("Sheet1").Protect Password:="123"

End Sub
1730117864656.png

1730117881200.png

This Error comes highlighting Option Explicit
 
Upvote 0
The error message is indicating you have additional text AFTER the macro that is not part of the macro.

Check and remove that extra text.
 
Upvote 0

Forum statistics

Threads
1,224,814
Messages
6,181,124
Members
453,021
Latest member
Justyna P

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