Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I am using Win XP, Excel 2003.
I receive a "Runtime Error '9': Subscript out of range" message. Code:
Dim bOK2Use As Boolean Private Sub btnOK_Click() Dim bError As Boolean Dim sSName As String Dim p As DocumentProperty Dim bSetIt As Boolean bOK2Use = False bError = True If Len(txtUser.Text) 0 And Len(txtPass.Text) 0 Then bError = False Select Case txtUser.Text Case "user1" sSName = "Corp" If txtPass.Text < "u1pass" Then bError = True Case "user2" sSName = "Elect" If txtPass.Text < "u2pass" Then bError = True Case Else bError = True End Select End If If bError Then MsgBox "Invalid User Name or Password" Else 'Set document property bSetIt = False For Each p In ActiveWorkbook.CustomDocumentProperties If p.Name = "auth" Then p.Value = sSName bSetIt = True Exit For End If Next p If Not bSetIt Then ActiveWorkbook.CustomDocumentProperties.Add _ Name:="auth", LinkToContent:=False, _ Type:=msoPropertyTypeString, Value:=sSName End If Sheets(sSName).Visible = True Sheets(sSName).Unprotect (txtPass.Text) Sheets(sSName).Activate bOK2Use = True Unload UserForm1 End If End Sub Private Sub UserForm_Terminate() If Not bOK2Use Then ActiveWorkbook.Close (False) End If End Sub The sheet names are Corp and Elect. What I am trying to do is have the user enter the Name and password on a userform to access a specific worksheet. What is the problem? |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
xpath error? Runtime Error 13 type mismatch | Excel Discussion (Misc queries) | |||
runtime error: syntax error or access violation | Excel Programming | |||
runtime error: syntax error or access violation | Excel Programming | |||
Excel 2003 Macro Error - Runtime error 1004 | Excel Discussion (Misc queries) | |||
Syntax Error Runtime Error '424' Object Required | Excel Programming |