![]() |
How to protect my macro
I am using macro to protect and unprotect a multi worksheet-workbook, how can
I stop data entry person from running unprotect macro when it is protected? If I use private for my macro, how can I see them myself to run protect or unprotect when needed. Thanks |
Maybe you could have your macro prompt you for a password:
if inputbox("what's the key") < "hiThere" then exit sub Or name the macro something no one else will guess. But instead of selecting it, you'll have to type it in the macro dialog box. == You could even have it check to see who's logged on to the network: Option Explicit Private Declare Function apiGetUserName Lib "advapi32.dll" Alias _ "GetUserNameA" (ByVal lpBuffer As String, nSize As Long) As Long Sub topsecret() If fOSUserName < "David Peterson" Then Exit Sub MsgBox "hi there" End Sub Function fOSUserName() As String ' Returns the network login name Dim lngLen As Long, lngX As Long Dim strUserName As String strUserName = String$(254, 0) lngLen = 255 lngX = apiGetUserName(strUserName, lngLen) If lngX < 0 Then fOSUserName = Left$(strUserName, lngLen - 1) Else fOSUserName = "" End If End Function Protect & Unprotect Several Worksheets wrote: I am using macro to protect and unprotect a multi worksheet-workbook, how can I stop data entry person from running unprotect macro when it is protected? If I use private for my macro, how can I see them myself to run protect or unprotect when needed. Thanks -- Dave Peterson |
All times are GMT +1. The time now is 04:54 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com