password for macro

K

kalpesh

Hello

it is possible to crate a password to run macr

mea

when i click command button to run a macro to ask password for run whic
restricted other person to use macro
 
C

Charlotte E.

Well, just use a simple InputBox, and don't forget to hide/protect your
VBA-code.

Be aware, however, that any determined intermediate user with no problem
can crack any Excel-code within 5 minutes...


CE



Den 09.02.2012 17:55, kalpesh skrev:
 
G

Gord Dibben

Sub test()
pword = InputBox("Enter the password")
If pword <> "drowssap" Then GoTo oops
MsgBox "you got it right" 'your code goes here
Exit Sub
oops:
MsgBox "try again"
End Sub


Make sure you add VBA protection so's users cannot see code.

In the VBE right-click on the workbook/project and
Properties>Protection>Lock for Viewing and password it with some other
password..........DO NOT forget it.

Save, close and re-open before locking takes place.


Gord
 
G

GS

Charlotte E. submitted this idea :
Be aware, however, that any determined intermediate user with no problem can
crack any Excel-code within 5 minutes...

Actually, it takes less than 1 minute to clear a file of all passwords,
including open password, wkb/wks protection, and VBA project.
 

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