I am getting a "Next without For" error which I don't understand.
I have a UserForm with 2 TextBoxes and 1 ComboBox:

When I click Submit button, I want to check if the serial number matches existing data in column 4. In this case, I want the data to fill in the disposition column (3 rows to the right) with text from ComboBox1.
If it does match I want to fill a brand new row.
If no disposition is inputted, I want to exit the sub or message box. Either is ok.
I tried re-arranging If, Else, For, Next but nothing seems to work.
Private Sub SubmitButton_Click()
Dim serial_ID As String
serial_ID = Trim(SN_TextBox1.Text)
DispValue = ComboBox1.Value
Worksheets("RMA Tracker").Activate
lastrow = ActiveSheet.Cells(Rows.Count, 4).End(xlUp).Row
For i = 2 To lastrow
'Searches for matching RMA & SN 'this assigns data to Log Sheet, if the data is brand new
If Worksheets("Sheet1").Cells(i, 4).Value <> serial_ID Then
ActiveSheet.Cells(i + 1, 1) = RMA_TextBox1.Value
ActiveSheet.Cells(i + 1, 4) = SN_TextBox1.Value
ActiveSheet.Cells(i + 1, 7) = ComboBox1.Value
Else
'this assigns data to disposition column to matching entries in serial number column
If Worksheets("Sheet1").Cells(i, 4).Value = serial_ID Then
ComboBox1.Text = Worksheets("Sheet1").Cells(i, 7).Value
Else
If DispValue = "" Then
Exit Sub
End If
Next i
'this clears the fields of userform when button is clicked and saves it automatically
ActiveWorkbook.Save
Call resetform
End Sub
SubandEnd Sub, hit Tab; then select every line betweenForandNext i, and successively indent entire nested code blocks like this, until you eventually hit the inevitable "oh." and add the missingEnd If. The best way to avoid this compile error is to consistently close every block you open, as soon as it's opened: typeIf {condition} Then<ENTER>, follow it withEnd Ifimmediately and insert the body (at +1 indent level) - that will never fail you =)