Home > Mobile >  Else without if vba
Else without if vba

Time:02-28

I'm beginner. Could you tell me why I have error "Else without IF"?

If ComboBox3.Value = "" Then FROM = ""
ElseIf ComboBox3.Value = "" Then FROM = ""
ElseIf ComboBox3.Value = "" Then FROM = ""
ElseIf ComboBox3.Value = "" Then FROM = ""
ElseIf ComboBox3.Value = "" Then FROM = ""
ElseIf ComboBox3.Value = "" Then FROM = ""
ElseIf ComboBox3.Value = "" Then FROM = ""
ElseIf ComboBox3.Value = "" Then FROM = ""
ElseIf ComboBox3.Value = "" Then FROM = ""
ElseIf ComboBox3.Value = "" Then FROM = ""
Else: FROM = ""

End If

CodePudding user response:

Else: FROM = ""
'Notice the colon after the `Else`

Edit: The error at the first ElseIf is caused by the implicitely closed If. You would have to go to a new line after Then or the If will be closed implicitely.

'Fixed Code:
If ComboBox3.Value = "" Then
    FROM = ""
ElseIf ComboBox3.Value = "" Then
    FROM = ""
'Your code continue...
End If
  • Related