HOW TO LOCK/STOP THE OPENING OF 1 SHEET AMONG 3 IN 1 EXCEL FILE?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

The thing is that I have an Excel file with 4 sheets in it.
I want 2 person one after the other to work on the very same file on the
same PC. I want the first one to be able to work on the 4 sheets of the file
and the second to be able to work and see only the two first sheets of the
very same file in the same PC...but not the 2 others which I would like to
protect 'alone' with a password.

How can this be done?

Thank you so much for your help
 
Paste the below code in the Open event of the workbook. You will have to use
the macro Editor, select the workbook on the left hand pane.

Dim mPasswd As String
Dim i As Integer
'Hide last 2 worksheets
Sheets(2).Visible = 2
Sheets(3).Visible = 2
'prompt for the password
mPasswd = InputBox("Please enter the password!!", "Worksheet locker")
'if the password is correct, show all worksheets
If mPasswd = "test" Then
For Each sht In ActiveWorkbook.Sheets
sht.Visible = True
Next
Else
'Hide the worksheet
Sheets(2).Visible = 2
Sheets(3).Visible = 2
End If

You can make necessary changes to suit this to your requirements.

Hope this helps!!
 
Back
Top