Hello ripps, welcome to PCHF.
Excel does not have the facility to assign as password to a Macro itself. However there are some alternative ways that may help.
Password protect the Excel document itself
This is the easiest method, but won't work for you, if you want your users to be able to modify the document, but not edit protected cells.
You can assign both Read Only and Modify passwords, by going to
File, Save As, click on
Tools on the top right hand corner of the "Save As" window, followed by
General Options.
Assign a password to Protect your sheet
When you go to
Tools, Protection, Protect Sheet it will automatically request for a password to assign. If this is all the Macro does, then I don't see much point in creating a complete Macro to perform such a basic function.
Request for a password in the Macro itself
Edit your macro, and insert the following lines after the second line (sub):
Dim pw
pw = InputBox("Please enter Password:")
If pw = "pa$$w0rd" then
And the following just before the last line (end sub):
End If
This will work, however, it's not that secure, as anybody can go into the Macro and realise that the password is
pa$$w0rd!
EDIT: Marked as Answered.
