Password protect a sheet?

NewGuy321

New Member
Joined
Nov 4, 2004
Messages
27
Is it possible to password protect a certain sheet so when a user attempts to view it the user is prompted for a password. Im trying to password protect a sheet from viewing as it will contain data only certain users of the system can view. Thanx in advance
 

Excel Facts

Is there a shortcut key for strikethrough?
Ctrl+S is used for Save. Ctrl+5 is used for Strikethrough. Why Ctrl+5? When you use hashmarks to count |||| is 4, strike through to mean 5.
I'm not sure if you can password protect the sheet
from viewing. You can password protect certain cells
from allowing changes.
Look under format/sheet/hide which will hide the
sheet but that is pretty easily undone by those that
are familar with Excel.
Maybe some of the guru's that I learn from will be
able to tell you how to password protect it.
Good Luck!
 
Upvote 0
You can use a worksheet activate event:
Code:
Private Sub Worksheet_Activate()
    Dim ans As String
        ans = InputBox("Please enter your password", "Password Required")
            '   Set password
            '   If wrong, return to master sheet
            If ans <> "password" Then Sheets("Sheet2").Activate
End Sub
If the user gets the password wrong, they're eturned to the sheet that you specify. Note that they can still see the sheet while entering a password.

PM me your e-mail address and I'll send you a workbook that allows you to specify the sheets users are allowed to view and you can assign individual passwords.

HTH,

Smitty
 
Upvote 0
you can draw a rectangle over a part of your sheet, and then to protect the sheet with a password
when the user know the password, he can just delete it, OR
doing it more smart under macro (hide the rectangle or unhde it)
 
Upvote 0
This has been asked before, this is a reply from that

Add this to the "This workbook" code

'Re: Password protect single worksheet
'Posted by Juan Pablo on October 16, 2001 9:13 AM

Public PvSh As String
Public Pwd As String

Private Sub Workbook_SheetActivate(ByVal Sh As Object)
If Pwd = "" Then
If Sh.Name = "Sheet2" Then
Num = ActiveWindow.Index
Windows(Num).Visible = False
If Application.InputBox("Enter Password", "Password") <> "airplane" Then
MsgBox "Incorrect Password", vbCritical, "Error"
Application.EnableEvents = False
Sheets(PvSh).Select
Application.EnableEvents = True
Else
Pwd = "airplane"
End If
Windows(Num).Visible = True
End If
End If
End Sub

Private Sub Workbook_SheetDeactivate(ByVal Sh As Object)
PvSh = Sh.Name
End Sub

From sheet1 click on Sheet2, a password dialogue box appears with a blank background.

You may wish to password protect the vb code from viewing or anyone can see the password written in the code.

John
 
Upvote 0

Forum statistics

Threads
1,215,026
Messages
6,122,738
Members
449,094
Latest member
dsharae57

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