So I was trying to connect the update button to my excel sheet which contain employee's number, name and department.
How it function is the user need to input the employee's number then it will display the name and the employee's department (which I'm done with it already) Then the user can change the name as well as the department and press the update button which is where the problem comes in now.
Everytime I press the update button, it will display "Compile error: End if without block If"
Private Sub btn_Update_Click()
Dim lastRow As Integer
Dim empNum As Integer
Dim rowSelect As Integer
Dim x As Integer
If Trim(txt_EmpNo.Value) = vbNullString Then
MsgBox "The Employee's No cannot be blank!"
Else
empNum = txt_EmpNo.Value
Sheets("LUNCH ORDER").Select
Set ws = Worksheets("LUNCH ORDER")
lastRow = ws.Cells(Rows.Count, 3).End(xlUp).Row
For x = 2 To lastRow
If ws.Cells(x, 3).Values = empNum Then Rows(x).Select
End If
Next
rowSelect = ActiveCell.Row
Cells(rowSelect, 2) = Me.txt_Name.Value
Cells(rowSelect, 3) = Me.txt_Dept.Value
End If
End Sub