I found some username and password login code that I am editing for my needs, but I am having some trouble with it. I keep getting run time error '448': Named argument not found on the following line:
MatchCase:=False, SearchFormat:=False)
Code:
Private Sub CommandButton3_Click()
Dim RowNo As Long
Dim Id As String, pw As String
Dim ws As Worksheet
Dim aCell As Range
If Len(Trim(Me.Username.Value)) = 0 Then
Me.Username.Value.SetFocus
MsgBox "Username cannot be empty"
Exit Sub
End If
If Len(Trim(Password)) = 0 Then
Password.SetFocus
MsgBox "Password cannot be empty"
Exit Sub
End If
Application.ScreenUpdating = False
Set ws = Worksheets("Users")
Id = LCase(Me.Username.Value)
Set aCell = ws.Columns(1).Find(What:=Id, LookIn:=xlValues, _
LookAt:=xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False, SearchFormat:=False)
'~~> If match found
If Not aCell Is Nothing Then
RowNo = aCell.Row
If Me.Password = aCell.Offset(, 1) Then
Sheets("Users").Range("G1").Value = Usernames.Value
Unload Me
Else
MsgBox "Unable to match UserID or PasswordID, Please try again", vbOKOnly
End If
Else '<~~ If not found
MsgBox "Unable to match UserID or PasswordID, Please try again", vbOKOnly
End If
CleanExit:
Set ws = Nothing
Application.ScreenUpdating = True
Exit Sub
End Sub
I have also attached my workbook.
Bookmarks