Password Protecting Macros

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

In Excel 2003. how can I restrict different users within the same file from
running the same macro? Is there a way to password protect a macro so that
only the designated user with the correct password can run the macro
(currently I'm using buttons to initiate the macros)?
 
Add in a validation procedure that verifies whether the user is allowed to
run the specific macro. Create a sheet which will be set very hidden so that
the user can not see it (without getting inot the code) and designate the
users who should be allowed to run the macro The list will be their NT user
names. Your functin will check the NT username against the list. To get the
username use Environ("User Name)... so the function will look something like
this... (untested)

public function AuthorizedUser () as boolean
dim rngFound as range
dim rngToSearch As range
dim wks as worksheet

set wks = sheets("My Users")
set rngtosearch = wks.range("A:A")
set rngfound = rngtosearch.find(Environ("User Name"))

if rngfound is nothing then
AuthorizedUser = false
else
AuthorizedUser = true
end if
end function
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top