Storing input to a cell in excel
-
:~ Okay, This is proably a no brainer for you folks but I am new to programming at this level, so please bear with me; The Objective; to save the users input string to a cell after it has been verified. The problem; when I run the code to debug it I currently get a "Runtime error 9 -subscript out of range" . I would also ask that there must be a better way to store the password all suggestions are welcomed on that one and can anyone tell me what I need to use to mask the users input with a single repeated character. Here's my current code:
Private Sub CommandButton2_Click() Dim Tb As Integer, PwdSv As String, Field As String Set Workbooks("XTSR").Sheets("Sheet14").Range("C17").Value = PwdSv Set Workbooks("XTSR").Sheets("Sheet14").Range("C6:C11").Value = Field For Tb = 1 To 6 If Field = "" And PwdSv = "" Then Call password_new Next Tb If PwdSv <> "" Then Call Password End Sub Public Sub password_new() Dim Default, Msg1, Msg2, Style, Title1, Title2, PwdSv RESTART: Default = "" Msg1 = "Enter a Password" Msg2 = "Re-enter Password to Confirm it" Msg3 = "Entries Did Not Match, Try Again!" Set PwdSv = Workbooks("XTSR").Sheets("Sheet14").Range("C17").Value Title1 = "Password Confirmation" Title2 = "Password Error" Style = vbOKOnly + vbExclamation + vbApplicationModal Open "Ltrt.pws" For Output As #1 strPwd1 = InputBox(Msg1, Title1, Default, 100, 100) strPwd2 = InputBox(Msg2, Title1, Default, 100, 100) Write #1, strPwd1, strPwd2 Close #1 Open "Ltrt.pws" For Input As #1 Line Input #1, strData Close #1 If strPwd1 = strPwd2 Then Set PwdSv = strPwd2 Else Response = MsgBox(Msg3, Style, Title2) If Response.Value = 0 Then GoTo RESTART End If End Sub Public Sub Password() Dim Compare, PwdSv, Msg1, Msg2, Style, Title1, Title2 Msg1 = "Please Enter Your Password" Msg2 = "Password Incorrect" Set PwdSv = Worksheet("Sheet14").Range("C17").Value Style = vbOKOnly + vbExclamation + vbApplicationModal Title1 = "Password Required" Title2 = "Password Volilation" Retry: Compare = InputBox(Msg1, Title1, 100, 100) If PwdSv = Compare Then Call ScreenFieldUnlock Else Response = MsgBox(Msg2, Style, Title2) If Response.Value = 0 Then GoTo Retry End Sub Public Sub ScreenFieldUnlock() TextBox1.Locked = False TextBox2.Locked = False TextBox3.Locked = False TextBox4.Locked