ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   how can I assign a password to a command button (https://www.excelbanter.com/excel-programming/349462-how-can-i-assign-password-command-button.html)

HELP!

how can I assign a password to a command button
 
I am trying to crearte a command button that asks me for a question when I
click on it. If I enter the correct password, then it should run.

Norman Jones

how can I assign a password to a command button
 
Hi Help,

Try something like:

'=============
Private Sub CommandButton1_Click()
Dim Res As Variant

Res = InputBox("Enter password")

If Res < "drowssap" Then
MsgBox "Password not recognised"
Exit Sub
End If

'Your button code

End Sub
'<<=============


---
Regards,
Norman


"Help!" wrote in message
...
I am trying to crearte a command button that asks me for a question when I
click on it. If I enter the correct password, then it should run.




Kevin B[_5_]

how can I assign a password to a command button
 
This actually doesn't apply a password per se, but it does require the
correct word or phrase before processing:

Private Sub CommandButton1_Click()

Dim strPassword As String

strPassword = InputBox("Enter the password for this " & _
"command button.")

If strPassword = "Password" Then
'Do something here
Else
MsgBox "You did not enter the correct password for " & _
"this command button."
End If

End Sub

--
Kevin Backmann


"Help!" wrote:

I am trying to crearte a command button that asks me for a question when I
click on it. If I enter the correct password, then it should run.



All times are GMT +1. The time now is 12:04 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com