Hi everyone,
Is there a way of putting a password on a macro button.
I.e user clicks on it and the user is prompted to enter a password.
I have done this in other code but not sure for vb
Cheers
Steve
Hi everyone,
Is there a way of putting a password on a macro button.
I.e user clicks on it and the user is prompted to enter a password.
I have done this in other code but not sure for vb
Cheers
Steve
You would have to use an InputBox to get the password and match the input to your passwoord
hi royuk,
I can do this but i was not clear in what i need..
I need to hide the password in the code, is that possible?
Dim the input as usual, then something along the lines of
If MyInput = "password" then
do something
Else do something else
End if
Create a name with the constant value of Your password then You refer to the name instead to it's value.
Steve,
How about
Dim strPassword As String
strPassword = InputBox("Password", "ENTER PASSWORD")
If strPassword = "" Then Exit Sub
If strPassword <> "Secret" Then
MsgBox "Incorrect Password"
Exit Sub
End If
'YOUR CODE HERE
Then password protect the VBE, Tools>VBAProject Properties - Protection. This will take effect when you save, close and re-open.
If you need to hide the password while being typed, you will need to use a UserForm and a TextBox, with the TextBox PasswordChar Property set to *
Don’t have an account yet? Register yourself now and be a part of our community!