Macro Protection

F

fodman

Hi again,

i have a simple macro that clears unlocked cell contents on a
worksheet. However, as the worksheet is used by several people its
possible one of them may run the macro...unlikely but i'd rather they
didn't have the choice. Is it possible to password protect the macro or
something similar?


Thanks.
 
N

Norman Jones

Hi Fodman,

If you preface your macro with the word Private, the macro will not show up
in the list of macros, e.g.:

Private Sub MyMacro

'Your code

End sub

Alternatvely, try something like:

'=============>>
Public Sub MyMacro()
Dim res As String

res = InputBox("Insert the password")

If res <> "YourPassword" Then
Exit Sub
End If

'Your code

End Sub
'<<=============
 
F

fodman

Am i missing something?....How then do* i *find the macro if it doessn't
show up in the macro list?

:confused:
 
N

Norman Jones

Hi Fodman,

Even though the macro will not show up in the macro dialog, you can run the
macro by typing the macro's name.

However, why not try my suggested password suggestion?
 

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