Hey Guys,
I am just working on a project and it requires that multiple people to login to one workbook with various access.
I use the code I got from below;
http://www.mrexcel.com/forum/excel-q...xcel-file.html
Private Sub Workbook_Open()
Dim Sh As Worksheet
Dim UserName As String
Dim Password As String
Dim ThisCell As Range
Dim c As Long
For Each Sh In ThisWorkbook.Worksheets
If Sh.Name <> "Welcome" Then
Sh.Visible = xlSheetVeryHidden
End If
Next Sh
UserName = InputBox("Please enter your user name.")
Password = InputBox("Please enter password.")
For Each ThisCell In Sheets("User List").Range("A2:A" & Sheets("User List").Range("A65536").End(xlUp).Row)
If UCase(ThisCell.Value) = UCase(UserName) And UCase(ThisCell.Offset(, 1).Value) = UCase(Password) Then
MsgBox "Access Granted"
For c = 2 To 4
'This is the number of sheets from C1 to E1
If ThisCell.Offset(, c).Value <> "" Then
Sheets(Sheets("User List").Cells(1, c + 1).Value).Visible = xlSheetVisible
End If
Next c
Exit Sub
End If
Next ThisCell
MsgBox "Access Denied"
ThisWorkbook.Close
End Sub
And this works perfectly fine but I need user to be able to amend his/her password after a successful login.
And if the logging fails I like the code to ask whether user want to close the workbook or want to try entering username and password again.
Also if user forgets his password it would be great if the code can send an email to user containing the password.
Finally I like to keep a log for each successful logins... Date, time and user name.Thanks for you help in advance.
Bookmarks