It works perfectly, failing each 'If' condition correctly... UNTIL you remove the 'Rem' on 'Do While' and 'Loop'. Then the final 'ElseIf' passes when it should fail, but note that both sets of code are identical.
I have simplified my code so as to eliminate anything to do with the spreadsheet that might have confused, or suggest it is the spreadsheet causing the problem.
This appears to be some kind of bug but I cannot get around it. Any ideas?
Code: Select all
Sub Update()
Dim count As Integer, a As Integer, b As Integer
count = 3 : a=4 : b=0
Rem Do While count > 0
count = count -1
'----------------------------------------------
If a = 6 Then
b=6
a=3
ElseIf a = 6 Then
a=4
End If
'-----------------------------------------------
If a = 6 Then
b=6
a=3
ElseIf a = 6 Then
a=4
End If
'-----------------------------------------------
Rem Loop
End Sub