How to protect macro cointained Worksheets and workbooks by using

H

Harshad

I have prepared 10-12 macros, which i want to protect by password.
I also want to protect worksheets and workbook that cointain above protected
macro.

Thank you in advance.
Harshad
 
K

Kevin B

To protect your macros press <Alt> + F11 to open the Visual Basic Editor.
The window in the upper-left corner, right below the toolbars, is the VBA
Project Explorer windows. Right-click on the VBAProject(YourWorkbookName)
icon and select properties. Click the protection tab, click the LOCK PROJET
FOR VIEWING check box to turn it on and enter and confirm the password.

As for the worksheets and workbooks, you can do that to each worksheet or to
the entire workbook from the menu. Click TOOLS and select PROTECTION and
then make the appropriate choices and enter & confirm your passwords.

Hope this helps...
 
J

JLatham

Excel Help and search for 'protect' or 'protection' for instructions on
protecting the workbook and/or worksheets.
In Excel 2003: in main menu Tools | Protect and choose either Workbook or
Worksheet. You may protect both, just not at the same time.

For the macros, in the VB Editor choose
Tools | VBAProject Properties and use the [Protection] tab.

Do no forget your passwords.
 
D

Dave Peterson

You can stop prying eyes from seeing your code by:

Inside the VBE
Tools|VBAProject Properties|Protection tab

This won't stop anyone who really wants to see your code.

If you want to stop users from running your code, you could add something like:

Option Explicit
Sub Test()

dim pwd as string
'more dim statements

pwd = Inputbox(Prompt:="What's the password?")

if pwd <> "YourSecretPassWordHere" then
msgbox "You can't run this"
exit sub
end if

'rest of code

End sub
 
H

Harshad

Dear Dave,

It's excellent macro. Very useful.

one thing more in the same, when i protect my code by password, it won't run
without password, BUT one can view macro and from that one can find the
password. Is their any solution?

with regards,
Harsahd
 
D

Dave Peterson

Protect the Project with a memorable password.

Save, close and reopen the workbook to test it.
 

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

Top