Is it possible to password protect a button?

Randal G

Board Regular
Joined
Feb 26, 2003
Messages
73
I have a button of which activates a macro to reset a work calculations calendar. It is important that I don't accidentally click the button till its time. I could just set it up manually enter the variable that would handle the resetc(which is what I had), but the button would be nice if I could just password or otherwise protect it.
If this is a VB solution... go easy on me. It's my short coming.
Thanks to any solutions
Randal G.
 

Excel Facts

Save Often
If you start asking yourself if now is a good time to save your Excel workbook, the answer is Yes
How about if you get a message box popup and ask if your sure you want to continue.

Take the msgbox code from the following example and place at top of your macro . It will pop up a msgbox that will ask if you want to continue ... if yo say no then it exits the procedure .... OK ?

Public Sub DemoCancel()
Msg = "Do you want to continue ?" ' Define message.
Style = vbYesNo + vbQuestion + vbDefaultButton2 ' Define buttons.
Title = "Reset Work Calculations" ' Define title.

Response = MsgBox(Msg, Style, Title)
If Response = vbNo Then Exit Sub


' PLACE YOUR CODE HERE !!!!!!!!!!!!


End Sub
 
Upvote 0
WELCOME TO THE BOARD!

Add this to the beginning of your macro:

Code:
Dim MyPassword As String
    MyPassword = "zebra"
    If InputBox("Please enter password to continue.", "Enter Password") <> MyPassword Then
        Exit Sub
        End If
 
Upvote 0
Heres a second example that ask user for a simple password... However if you don't lock your VBA editor then the User could find the Password pretty easy. :confused:

Public Sub DemoCancelV2()

Response = Application.InputBox("Enter Password to execute", "Password Required")

If Not Response = "OK2DO" Then Exit Sub

'PLACE YOUR CODE HERE !!!!!!!!!!!!!!!!!!
End Sub
 
Upvote 0
Nimrod said:
How about if you get a message box popup and ask if your sure you want to continue.

Take the msgbox code from the following example and place at top of your macro . It will pop up a msgbox that will ask if you want to continue ... if yo say no then it exits the procedure .... OK ?

Public Sub DemoCancel()
Msg = "Do you want to continue ?" ' Define message.
Style = vbYesNo + vbQuestion + vbDefaultButton2 ' Define buttons.
Title = "Reset Work Calculations" ' Define title.

Response = MsgBox(Msg, Style, Title)
If Response = vbNo Then Exit Sub



' PLACE YOUR CODE HERE !!!!!!!!!!!!


End Sub


:LOL: THIS IS THE TICKET AND BEATS MESSING WITH A PASSWORD..... MUCH THANKS :LOL: Randal G.
 
Upvote 0
Re: Is it possible to password protect a button ???

ALWAYS lock your VBA editor. People are sneaks.
 
Upvote 0
Re: WELCOME TO THE BOARD!

Add this to the beginning of your macro:

Code:
Dim MyPassword As String
    MyPassword = "zebra"
    If InputBox("Please enter password to continue.", "Enter Password") <> MyPassword Then
        Exit Sub
        End If

How to re-pop up password tab if someone put wrong password?
 
Upvote 0
Re: WELCOME TO THE BOARD!

Hello, i don't know about VBA. i used your code. How i set password tab to pop-up again if someone write wrong password?
 
Upvote 0
Re: WELCOME TO THE BOARD!

How about
Code:
Sub Pword()

    Dim Ans As Boolean
    Const Pword As String = "Zebra"
    
    Ans = False
    
    Do While Ans = False
        If InputBox("Please enter password to continue.", "Enter Password") = Pword Then
            Ans = True
        End If
    Loop

End Sub
 
Upvote 0

Forum statistics

Threads
1,215,135
Messages
6,123,239
Members
449,093
Latest member
Vincent Khandagale

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