Hey everyone
I havent been on here for a while but I hope someone can help me.
I am using the following code on a userform to force the users to 'log in' to view the sheets. I used a Auto Open macro to bring up the form when the file is opened.
Private Sub btn_Cancel_Click()
Unload Me
Sheets("Simon").Visible = xlSheetVeryHidden
Sheets("Melissa").Visible = xlSheetVeryHidden
Sheets("Victoria").Visible = xlSheetVeryHidden
Sheets("AnneMarie").Visible = xlSheetVeryHidden
End Sub
Private Sub btn_Login_Click()
Dim PW As String
Dim ID As String
Dim Passwords As Range
Dim First_PW As Range
Dim Last_PW As Integer
Dim ID_PW_OK As Boolean
Dim X As Integer
Set First_PW = Sheets("USERS").Range("A1")
Last_PW = First_PW.Offset(1000, 0).End(xlUp).Row
Set Passwords = First_PW.Resize(Last_PW, 2)
ID_PW_OK = False
With Me
PW = UCase(Application.WorksheetFunction.Trim(.txt_PW))
ID = UCase(Application.WorksheetFunction.Trim(.txt_ID))
For X = 1 To Last_PW
If UCase(Application.WorksheetFunction.Trim(First_PW.Offset(X - 1, 0))) = ID _
And UCase(Application.WorksheetFunction.Trim(First_PW.Offset(X - 1, 1))) = PW Then
ID_PW_OK = True
Unload Me
MsgBox "Access Granted"
Sheets("Simon").Visible = True
Sheets("Melissa").Visible = True
Sheets("Victoria").Visible = True
Sheets("AnneMarie").Visible = True
Sheets("START").Visible = xlSheetVeryHidden
Sheets("Simon").Select
Exit For
End If
Next X
If ID_PW_OK = False Then
MsgBox "Invalid ID and/or password. Try Again."
End If
End With
End Sub
Private Sub Label3_Click()
End Sub
Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer)
If CloseMode = vbcontrolmenu Then Cancel = True
Exit Sub
End Sub
This all works fine.....HOWEVER....
I need to make it so that if a user logs in using the name 'Simon' they would only see the 'Simon' sheet. And the same for all of the other users.
Any ideas on how I can mod this code to do that for me??
Any help is much appreciated
Simon
Bookmarks