Password Protect A Macro Button

MIRPAX

New Member
Joined
Apr 18, 2013
Messages
12
I have a worksheet that I only want certain users running the VBA code. I would like to somehow password protect the macro button so that only selected users can run it. Is this possible?
 

Excel Facts

Which came first: VisiCalc or Lotus 1-2-3?
Dan Bricklin and Bob Frankston debuted VisiCalc in 1979 as a Visible Calculator. Lotus 1-2-3 debuted in the early 1980's, from Mitch Kapor.
Using the information from: Password Protect Excel Macro - EASY Excel VBA
You can set up a code at the beginning of your macro to prompt you for a password.
The code is below:
Code:
Dim password As Variant
              password = Application.InputBox("Enter Password", "Password Protected")

Select Case password
                  Case Is = False
                      'do nothing
                  Case Is = "PASSWORD" 'Edit this line with the password you wish to protect your macro with.
                      'This is where your code will go.
                  Case Else
                      MsgBox "Incorrect Password"
End Select


Edit: If you want to lock it from viewing and editing (so that they can't change the password in the coding or figure out the password and use it), please refer to the thread I linked above.

Hope this answers your question!
 
Last edited:
Upvote 0
Show us the script in your button.
We can provide some protection but a determined user with enough knowledge can do most anything with excel.
 
Upvote 0
MattH1 - This is exactly what I was looking for. Thank you for your sharing your knowledge so quickly!
 
Upvote 0

Forum statistics

Threads
1,214,613
Messages
6,120,515
Members
448,968
Latest member
Ajax40

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