Protection‎ > ‎

Pwd to View Sht

"I have a sheet2 with a lot of setups and proprietary information I do not want my users to access. I'd like to be able to access it without having to keep hiding and unhiding it. Can the sheet be password protected from VIEWING?"

  1. Sheet tab remains visible
  2. Users cannot see any information on sheet even when they click the sheet tab until password is given
  3. Prompt for password should be automatic
  4. Correct password, sheet becomes visible and editable
  5. Incorrect password, switch back to Sheet1
  1. This is a sheet-event macro, it triggers when sheet tab is selected
  2. Right-click on the sheet2 tab and select VIEW CODE
  3. Paste in the macro code given below
  4. Edit the password at the top to the one you want to require
  5. Edit the Sheet1 reference to the sheet you want to switch to when the wrong password is given
  6. Close the VB editor
  7. Save as a macro-enabled workbook


Option Explicit

Private Sub Worksheet_Activate()
Dim pwd As String:  pwd = "password"

Cells(Rows.Count, Columns.Count).Activate
    If Application.InputBox("What is the password to view this sheet?", "Access Password", "???") <> pwd Then
        MsgBox "Wrong password"
    End If
End Sub

Nothing says "thanks" like a steak dinner!
PayPal - The safer, easier way to pay online!