Hide sheet from view with password

nparsons75

Well-known Member
Joined
Sep 23, 2013
Messages
1,256
Office Version
  1. 2016
Hi,

I have an excel file containing a number of sheets, I will name them sheet 1,2,3,4 and 5.

The issue I have have is this.

Sheet 1 and 2 need to be restricted access. Only certain people can view / edit as they contain sensitive data. Sheets 3,4 and 5 are open access and can be viewed by anyone.

Is there a way of password protecting or another method so that that only certain people can access sheet 1 and 2.

Currently to do this I am having to have two independent workbooks (restricted and open access).

Thanks
 
This should work
Code:
Private Sub Workbook_Open()
havepass = MsgBox("Put your do you want to unhide sheet text here", vbYesNo + vbQuestion)
If havepass = vbYes Then
retry:
    pword = InputBox("enter password")
    If pword = vbNullString Then Exit Sub
    If pword = "password" Then
        Sheets("Sheet1").Visible = True
        Sheets("Sheet2").Visible = True
        Sheets("Sheet1").Unprotect ("passwordhere")
        Sheets("Sheet2").Unprotect ("passwordhere")
        Sheets("Sheet1").Activate 'change this to the sheet you want to be active when the correct password is entered.
    Else
        MsgBox ("please try again")
        GoTo retry
    End If
  
End If
 
End Sub
 
Upvote 0

Excel Facts

Workdays for a market open Mon, Wed, Friday?
Yes! Use "0101011" for the weekend argument in NETWORKDAYS.INTL or WORKDAY.INTL. The 7 digits start on Monday. 1 means it is a weekend.

Forum statistics

Threads
1,224,828
Messages
6,181,210
Members
453,023
Latest member
alabaz

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