View Single Post
  #8   Report Post  
Posted to microsoft.public.excel.programming
John John is offline
external usenet poster
 
Posts: 141
Default Password Protect Running of Macro

Thanks R.Bell, thats neat


"r.bell321" wrote in message
...

The original subroutine would have to read:
Sub PasswordForAMacro()
Userform1.Show
End Sub

You would need a userform (called Userform1) with a text box (called
Textbox1 with PasswordChar property set to "*") and a button (called
Button1) to submit the userform. Then put the following code in the
userform

Sub Button1_Click()
If Textbox1.text < "1234" Then
MsgBox "Invalid password - you cannot access this"
Userform1.Hide
Exit Sub
Else
'type the actions / code you require to run'
Userform1.Hide
End If


--
r.bell321Posted from - http://www.officehelp.in