Hiding a password

styler

Board Regular
Joined
May 22, 2003
Messages
77
Me again, and again with a lot of help from this board I have added a tick box that allows a person to lock out the sheet if they know the password.
I have two more questions to tweak this feature I have added.

1) Is there any way I can turn the password into *****'s in the code. The problem I have is that I will need several of these approval buttons that do certain things. This means that I will need several different passwords and I don't want to know them! neither do I want anyone else to know them. I know I can lock out the code but when one of the 3 people need to add their password or if I need to tweak the code when the sheet is in full use I will see it and turn to stone!! :)

2) When I untick the box, I get the password thing again which is ok but I would like to unlock the sheet again, can this be done.

I have attached the code I have for this tickbox password thing below.

Once again I bow to your support and enthusiasm.

Si


Private Sub Approve1_Click()
'
' lockout Macro
' Macro recorded 10/01/2005 by simontyler
'
line0:
P1$ = InputBox("Please enter password or press cancel")
If P1$ = "" Then GoTo line1:
If P1$ = "cen" Then GoTo line2
line1:
MsgBox ("Please enter a password")
GoTo line0
line2:
ActiveSheet.Protect P1$
Sheets("Extra").Protect P1$
End Sub
 

Excel Facts

Show numbers in thousands?
Use a custom number format of #,##0,K. Each comma after the final 0 will divide the displayed number by another thousand
Richie,

I had a look at option 1 and it does say that it will only work on office 2k. Which may be a problem. Besides, I pasted it in and loads of errors came up so I thought I'd have a look at your second idea and fall back on plan a later.
I'm not sure how to do what you suggested here, I know what a textbox is but a textbox on a userform? can you walk me through this one or is it a case of completely re-designing the form?

Si
 
Upvote 0
Hi Si,

1. In the VBE go to the Insert menu and choose UserForm.

2. You should see a Toolbox menu appear alongside the UF (if not select Toolbox from the View menu).

3. Left-click on a TextBox (starts ab) in the Toolbox and then left-click on the UF to paste the Textbox.

4. Repeat the process above but this time add a CommandButton (small, grey rectangle)

5. Select the TextBox and in the Properties window navigate to the PasswordChar property. Add an asterisk. (If the Properties window is not visible press F4).

6. Double-click on the CommandButton and add the following code:
Code:
Private Sub CommandButton1_Click()
    Me.Hide
End Sub
7. Amend your main routine to something like this:
Code:
Sub Approve1()
    Dim strPwdInput As String, bOk As Boolean
    Const strPwd As String = "letmein"
    
    Do
        UserForm1.Show
        strPwdInput = UserForm1.TextBox1.Text
        If strPwdInput = strPwd Then
            bOk = True
        Else
            bOk = False
            UserForm1.TextBox1.Text = ""
            UserForm1.TextBox1.SetFocus
        End If
    Loop Until bOk = True
        
    ActiveSheet.Protect Password:=strPwdInput
    
End Sub
8. Tidy-up as required - adding captions to the UF etc.

HTH
 
Upvote 0
Thanks for the precise details. I text-out the previous command and added your one, how do you get the form up? nothing appears anywere. How do I get the textbox to come up when the tick box is activated?
 
Upvote 0

Forum statistics

Threads
1,203,693
Messages
6,056,760
Members
444,889
Latest member
ibbara

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