• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

I need to put a password in the first button call "clients"

Corrie80405

New Member
Good Evening,

I wander if it's possible to put a password in when I press on the button "Clients" Only.
Then it asks you for a password.
Sheet 2 clients must not be visible if you do not have the password.

The other sheet may show if you click on them.

Thanks
 

Attachments

  • Test.xlsm
    433.2 KB · Views: 6
Since you did not provide the workbook password, I just used ken for both.

Make a userform with a textbox and command button. In it:
Code:
Private Sub UserForm_Initialize()
    TextBox1.PasswordChar = "*"  'Or set masking character at design time and not use this Sub.
End Sub

Private Sub CommandButton1_Click()
    If TextBox1 = "ken" Then
        ThisWorkbook.Unprotect "ken"
        Worksheets("Clients").Visible = xlSheetVisible
        ThisWorkbook.Protect "ken"
    End If
    Unload Me
End Sub
After or before Unload Me. you can call the other routine to show another userform.

If needed, you can hide it at close. In ThisWorkbook object:
Code:
Private Sub Workbook_BeforeClose(Cancel As Boolean)
    ThisWorkbook.Unprotect "ken"
    Worksheets("Clients").Visible = xlSheetHidden
    ThisWorkbook.Protect "ken"
End Sub
 
Hi Kennith,
I have done as you instructed and its not working.
Please see attached.
Thanks
 

Attachments

  • Test.xlsm
    434.3 KB · Views: 5
Since you did not provide the workbook password, I just used ken for both.
How could it work? You did not change the workbook password to ken or the code to use your password.

1. Change code or
2. Make workbook password to be ken. Set in Review ribbon.
 
Back
Top