Questions ArchiveCategory: Questionsvba-project-if-then-else-statements
Bethany asked 3 years ago

I keep getting an error message on my If, then, else code and cannot figure out what is wrong. I have looked up multiple examples and watched several of the videos and still can\\\’t figure out why none of mine will work.  here is one of them: If numHours <= 5 Then OH = 0 Else: OH = numHours – 5 End If

1 Answers
Cairo answered 3 years ago

If condition Then [ statements ] [ Else elsestatements ]
Or, you can use the block form syntax:
If condition Then
statements ]
ElseIf condition-n Then
elseifstatements ]]
elsestatements ]]
End If
It is possible that something is wrong and you need spaces inbetween the <= and = and -. Try that, also Googling errors works pretty well usually to debug.
Email if you still have issues!

Your Answer

3 + 9 =