Hi everyone<o></o>
I’m trying to create a login form that will grant access to the workbook and its sheets based on data stored in a sheet named ‘admin control’. <o></o>
The admin control sheet has three tables. One table (range A2:A21) that lists the sheet names (populated by a macro), another table (C2:D6) that holds the user name (C) and password (D) of the persons who will have full access to the entire workbook and the third table (F2:M17) holds the user name (F) and password (G) as well as the sheet names (H:M) of the sheets I want that person to be able to access. <o></o>
What I want to be able to do is take the login info entered by the user and compare it to the data in the admin group, if there is a match then close the form and open the workbook to the admin control sheet, all worksheets are visible. If there isn’t a match in that table, then check to see if there is a match in the next table. If a match is found, then set only the sheets listed to the right (H-M) as visible.
Any help is much appreciated
I've been trying to work out the first part; validating user info against admin group. This is what I have
but it gives me a type mismatch error on this line
I’m trying to create a login form that will grant access to the workbook and its sheets based on data stored in a sheet named ‘admin control’. <o></o>
The admin control sheet has three tables. One table (range A2:A21) that lists the sheet names (populated by a macro), another table (C2:D6) that holds the user name (C) and password (D) of the persons who will have full access to the entire workbook and the third table (F2:M17) holds the user name (F) and password (G) as well as the sheet names (H:M) of the sheets I want that person to be able to access. <o></o>
What I want to be able to do is take the login info entered by the user and compare it to the data in the admin group, if there is a match then close the form and open the workbook to the admin control sheet, all worksheets are visible. If there isn’t a match in that table, then check to see if there is a match in the next table. If a match is found, then set only the sheets listed to the right (H-M) as visible.
Any help is much appreciated
I've been trying to work out the first part; validating user info against admin group. This is what I have
Code:
Private Sub CommandButton1_Click()
'declaring variables
Dim user As String
Dim pass As Variant
'assigning value to variables
user = Usertxtbox.Value
pass = Passtxtbox.Value
Login = user + pass
Set adminName = Sheet3.Range("C2:C6")
Set regUser = Sheet3.Range("F2:F17")
'validating username & passcode of admins & set access
For Each Login In adminName
If user = adminName.Value And pass = adminName.Offset(0, 1).Value Then
Unload Me
Sheet3.Select
End If
Next Login
end sub
Code:
f user = adminName.Value And pass = adminName.Offset(0, 1).Value Then