Password protecting worksheets

N

Nick

I have a workbook that contains a worksheet "test" that I would like
to allow certain users of the system to access it. This worksheet
contains
some text and a Command button that executes some system funtion.

I'm aware that you can hide worksheets and that you can password
protect worksheets. Here's the problem:

1. If I hide, i.e.

Private Sub Workbook_Open()
ActiveWorkbook.Worksheets("test").Visible = False
End Sub

you can still unhide this worksheet without any problem, i.e.

Menu: Format-Sheet-Unhide


2. If I password protect, i.e.

Private Sub Workbook_Open()
ActiveWorkbook.Worksheets("test").Protect Password:="aaa"
End Sub

users can still push the Command Button (which I don't want)


It could possibly be useful

if a user wants to unhide a worksheet, that action would be password
protected

or

if a user wants to access a worksheet, the action of clicking on the
worksheet tab would be prompted with a password

or

All activity on a worksheet would be frozen, i.e using Command Buttons
etc

or

<any other suggestions>

thanks in advance,
Nick
 
F

Frank Kabel

Hi
one simple solution. Why not add some lines of code to
your command button procedure:

....
dim res
res = inputbox "Enter password"
if res <> "your_password"
msgbox "wrong pwd"
exit sub
end if

'now your code
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top