Why does this IF-THEN line work without END IF?

I have a question about the If command.

For x = 2 To 8
If ComboBox1.ListCount < 7 Then ComboBox1.AddItem Cells(x, 13).Value
Next x'

Why does this work without errors? There is no End if statement. I don't know if this matters, but this code is in the UserForm_Activate () procedure.

Thanks for the help.

+3
source share
2 answers

You do not need End Ifto if Ifthere is only one operator, and it is on the same line as the operator If.

+5
source

VBA (and VB6 and VB.Net) do not require End Ifwhen the statement following the keyword Thenis on the same line of code.

+3
source

All Articles