Home |
Search |
Today's Posts |
#1
|
|||
|
|||
VBA for form
I'm trying to create a macro that will protect and unprotect 10 sheets in a workbook. i have the code to protect etc. i'm having a problem he i created a form named frmPassword where i have a text field called My_Password. what code would i use to open up that form and enter in a password, then when i click ok to assign whatever was in My_Password to a variable called My_Pass. I tried My_Pass=frmPassword.My_Password but that doesnt work, probably because i never opened the form. any help? -- tkaplan ------------------------------------------------------------------------ tkaplan's Profile: http://www.excelforum.com/member.php...o&userid=22987 View this thread: http://www.excelforum.com/showthread...hreadid=376355 |
#2
|
|||
|
|||
I put this in a general module.
Option Explicit Public myPass As String Sub testme() myPass = "" UserForm1.Show MsgBox myPass End Sub I created a userform (userform1) with a textbox and two buttons (ok and cancel). I put this code behind the userform: Option Explicit Private Sub CommandButton1_Click() Unload Me End Sub Private Sub CommandButton2_Click() myPass = Me.my_Password.Text Unload Me End Sub Running the sub TestMe shows the form and updates that myPass variable. tkaplan wrote: I'm trying to create a macro that will protect and unprotect 10 sheets in a workbook. i have the code to protect etc. i'm having a problem he i created a form named frmPassword where i have a text field called My_Password. what code would i use to open up that form and enter in a password, then when i click ok to assign whatever was in My_Password to a variable called My_Pass. I tried My_Pass=frmPassword.My_Password but that doesnt work, probably because i never opened the form. any help? -- tkaplan ------------------------------------------------------------------------ tkaplan's Profile: http://www.excelforum.com/member.php...o&userid=22987 View this thread: http://www.excelforum.com/showthread...hreadid=376355 -- Dave Peterson |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|