Password required to run macro

dmwilson38550m

Board Regular
Joined
Oct 29, 2010
Messages
67
Hi,

I wonder if someone can help. Is it possible to build a password into a macro so that a user can't run the macro programme in Excel unless they enter the correct password. So I was thinking of something like - run macro in Excel, request for passord/serial number comes up, enter password and macro continues running.

Many thanks,
David
 

Excel Facts

Difference between two dates
Secret function! Use =DATEDIF(A2,B2,"Y")&" years"&=DATEDIF(A2,B2,"YM")&" months"&=DATEDIF(A2,B2,"MD")&" days"
Simple enough, unless you forget to password protect the code, too, else they can just read the code to get the password. Add this one line near the top of your macro to do the password test:

Code:
IF Application.InputBox("Enter the password", "Password", Type:=2) <> "Mysecretpassword" then Exit Sub
 
Upvote 0

Forum statistics

Threads
1,224,618
Messages
6,179,917
Members
452,949
Latest member
beartooth91

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