if statement help in vba

virencm

Registered User.
Local time
Tomorrow, 02:55
Joined
Nov 13, 2009
Messages
61
Hi

New to VBA , Can some one please correct the code below. I ve heard that a select case statement might be even better then using If case statments. can you also please show me how to use the case statement for the code below? Thank you


If Left(Me.Engine, 1) = 6 Then
Engine_Type.Value = "PMC"

Else if Left(Me.Engine, 1) = 7 Then
Engine_Type.Value = "FADEC"

else
msgbox " Engine serial does not match engine type "

End If
End If
 
Start by removing 2nd End If otherwise syntax appears correct.

Have you verified the data is as expected?
 
There was a space between else and if. Thanks vbaInet.
 
Glad we could help.

If only all programming languages kept to one way of writing ElseIf. I prefer Else If (with a space) which some other languages use.
 

Users who are viewing this thread

Back
Top Bottom