I suspect the full code looks something like this:
If x = 1 or x=2 then y = 3
ElseIf x = 4 or x = 5 then y = 6
End if
If so, it should be
If x = 1 or x=2 then
y = 3
ElseIf x = 4 or x = 5 then
y = 6
End if
Incidentally, there is no need in
VB/VBA to enclose the
conditions in parentheses; IMHO it needlessly clutters
up the code.
On 6 Feb, 20:33, chrisnsmith
wrote:
Can someone explain to me why my Excel 2003 is not recognizing ( If )?
I've tried several codes with the If function and my code won't run.
If (this or that) Then...
and
If (this or that) Then....
Elseif (this or that) Then......
End If
In the first case the debugger says (End If without a block If).
In the second case the debugger says (ElseIf without a block If).