Block If without End If Compile Error

GoCavs

New Member
Joined
Jul 11, 2017
Messages
15
Hello All,

I have searched the boards and looked elsewhere but for whatever reason I cannot get this code to work for a password/login function I created. Whenever I enter the login credentials I get hit with a Compile Error: Block If without End If... I've had a few people look at it and we all feel like it's a quick fix that we just cant figure out.

Code:
Private Sub cmdLogin_Click()


Dim strUsername As String
Dim strPassword As String


Dim usr As Variant
Dim pwd As Variant


strUsername = txtUsername.Text
strPassword = txtPassword.Text


usr = Application.VLookup(txtUsername.Text, Range("Users"), 2, False)
pwd = Application.VLookup(txtPassword.Text, Range("Pass"), 2, False)


If IsError(usr) = False Then


If Application.VLookup(txtUsername.Text, Range("Users"), 2, 0) = _
txtPasswords.Text Then


MsgBox "Login Successful"
Unload frmLogin




'Sheets("Sales Input").Select


Else
MsgBox "Incorrect Login Information"


End If
End Sub
 

Excel Facts

Return population for a City
If you have a list of cities in A2:A100, use Data, Geography. Then =A2.Population and copy down.
Welcome to the forum.

The error message means exactly what it says: you have two If... Then clauses, and only one End If. Where the other one should be added will depend on what you want to happen exactly.
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,178
Members
453,021
Latest member
Justyna P

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top