I am trying to create a log-in page on a userform, frmlogin in "sheet3."
The userform is simply a textbox, Username (txtuser) and a textbox, Password (txtpass).
Command Button is cmdcheck
I want the User to enter their username and password and for my macro to verify that they match referencing data in a seperate worksheet, (Sheet6).
Upon verification I want the user to be unloaded on "sheet1"
I am currently getting this message:
"unable to get vlookup property of the worksheetfunction class"
I am new to vba and have spent way too much time on this one small issue. Please help me someone!!!!
Private Sub cmdcheck_Click()
Dim Username As String
Username = txtuser.Text
Dim password As String
password = txtpass.Text
'Check to see if data is entered into field: txtUserNameIn
If IsNull(Me.txtuser) Or Me.txtuser = "" Then
MsgBox "You must enter your username.", vbOKOnly, "Required Data"
Me.txtuser.SetFocus
Exit Sub
End If
'Check to see if data is entered into field: txtPasswordIn
If IsNull(Me.txtpass) Or Me.txtpass = "" Then
MsgBox "You must enter your Password (case sensitive).", vbOKOnly, "Required Data"
Me.txtpass.SetFocus
Exit Sub
End If
'Check to see if the Username & Password entered is a valid username in the 'User Register'
'****************
If Username = WorksheetFunction.VLookup(Me.txtuser.Value, Range("pass"), 2, 0) Then
'****************
If password = WorksheetFunction.VLookup(Me.txtuser.Value, Range("pass"), 3, 0) Then
MsgBox "Password & Username Accepted"
Unload Me
Sheets("landing").Select
Range("A1").Select
Else
MsgBox "Username & Password Combination Not Accepted"
Unload Me
End If
End If
End Sub
Bookmarks