Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

protect code

0 views
Skip to first unread message

Ivan en Sandra Lemaire

unread,
Nov 8, 2001, 7:10:25 PM11/8/01
to
Can somebody help me with the following;
On my worksheet i have got 2 buttons.
1 button is to unprotect the sheet and 1 button i use to lock selected
cells.
Problem: when i press the unprotect button and give the correct password,
the 2nd button appears, thats good. But when i press the unprotect button
and i give the wrong password or press the cancel button, the 2nd button
also appears. This is not good. And when i close the workbook the 2nd button
should be hidden so that the next time i open this workbook the second
button is not visible until i give the CORRECT password.
Thanks in advans.
This is the code i've written soo far:

Private Sub CommandButton6_Click()
ActiveSheet.Unprotect
Range("d13").Select
End Sub

Private Sub CommandButton7_Click()
Selection.Font.ColorIndex = 0
Selection.Locked = True
Selection.FormulaHidden = False
Range("a1").Select
End Sub
Private Sub Workbook_BeforeClose(Cancel As Boolean)
For i = 1 To Sheets.Count
Range("a1").Select
Sheets(i).Protect Contents:=True, Password:="mac2000"
Next i
End Sub

Dave

unread,
Nov 9, 2001, 5:10:34 PM11/9/01
to
sound like you need to se the visible property of you
button to false on close as well as having an if statement
in your unprotect

you unprotect button should be set up with either and
input box or a userform. The advnatage of the userform is
that you can set the textbox entry to * whereas the
inptubox you will see the password being typed.

I have short password userform..Email me if you want a
copy sent to you.

Dho...@uniongas.com

>.
>

0 new messages