View Single Post
  #6   Report Post  
Posted to microsoft.public.excel.programming
John John is offline
external usenet poster
 
Posts: 2,069
Default Password To Run Macro?

if you just want to limit access to macros to your use only, you could as an
idea, do a check on username.

see if this approach may work:

Public Const namecheck As String = "garyh"
Sub mymacro()
Dim myname As String

'get logon name
myname = Environ("UserName")

If myname = namecheck Then

'YOUR MACRO

Else

msg = MsgBox("You Are Not Authorised To Run Macro.", 16, "Warning")

End If
End Sub


if you want to prompt for password then an adding inputbox to probably the
simplest approach.

--
jb


"garyh" wrote:

Is there a way to request a password when a macro button is clicked? I
would like to 'lock' down the macros.

Thanks.

G