Help!

  • Thread starter Thread starter novice
  • Start date Start date
N

novice

Have 2 questions:

How do I place a password (Message Box) to protect code
from being executed (Assigned to a button command)?

How can I prevent the user from accessing the sheet tabs
(by using the "Options" feature also)?
 
Hi
1. Protecting your macro execution: One way:
- put the following code at the beginning of your macro:
sub foo()
Dim ret_pwd
ret_pwd = Application.inputbox("please enter your password")
if ret_pwd <>"your_password" then
msgbox "PWD was invalid"
exit sub
end if
'now your code follows
end sub

Note: This is not bullet proof. You also may protect your VBA code to
make it a little bit more difficult to read the password in your code

2. Not sure what you mean with this? You may hide the sheets and the
tabs and protect your workbook ('Tools - Protection')
 

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