ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Restricting activation of a form button (https://www.excelbanter.com/excel-programming/438621-restricting-activation-form-button.html)

Max

Restricting activation of a form button
 
I'm using 2 form buttons which runs 2 different subs. The buttons are on the
same sheet. I wish to restrict the activation of one of the 2 buttons
(assigned to the sub below) to only authorised persons via say, a password
prompt? which appears upon clicking the button. Grateful for an example or
two of how this control could be done. Thanks

Sub TestReset()
Sheet8.Select
Range("D10").Value = Range("G15").Value
Range("D11").Value = Range("D15").Value
End Sub

Cerberus

Restricting activation of a form button
 
I would try something like this:

Sub TestRest()
Sheet8.Select
Dim ThePassWord As String
Dim t As String
t = "What's the password"
ThePassWord = InputBox(prompt:=t)
If UCase(ThePassWord) = "BATTLEFIELD" Then
Range("D10").Value = Range("G15").Value
Else
MsgBox "That is incorrect."
End If
End Sub


The password would be BATTLEFIELD in this example

"Max" wrote:

I'm using 2 form buttons which runs 2 different subs. The buttons are on the
same sheet. I wish to restrict the activation of one of the 2 buttons
(assigned to the sub below) to only authorised persons via say, a password
prompt? which appears upon clicking the button. Grateful for an example or
two of how this control could be done. Thanks

Sub TestReset()
Sheet8.Select
Range("D10").Value = Range("G15").Value
Range("D11").Value = Range("D15").Value
End Sub


Max

Restricting activation of a form button
 
Thanks, Cerberus. How could it be re-expressed the other way around, ie
check the password, then exit sub immediately (with the error msg) if
password is incorrect?




All times are GMT +1. The time now is 07:18 AM.

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