I was shooting myself why the subroutine going totally wrong until i figured out that EXIT in Select..End Select and all this inside For..Next loop not working or at least tries to "exit" the Select block which is meaningless. Please forgive me if i am wrong.
For X = 0 To some_var
...blah blah
If some_condition=True Then Exit 'that works and exits For..Next
Select some_other_var
Case 5,7
Do_Some_Stuff (call other sub actually)
Exit ' i was instructing to Exit For..Next but that was wrong causing me headaches
End Select
other_commands
Next
End Sub
So in Select block if the some_other_var equals 5 or 7 does not exit For and continues to other_commands. This is known behavior, am i missing something? Or there is something else in my huge program?
I've replaced Exit with Return cause no need to stay in Sub after the condition in Select block is true, and all returned to normal.
For X = 0 To some_var
...blah blah
If some_condition=True Then Exit 'that works and exits For..Next
Select some_other_var
Case 5,7
Do_Some_Stuff (call other sub actually)
Exit ' i was instructing to Exit For..Next but that was wrong causing me headaches
End Select
other_commands
Next
End Sub
So in Select block if the some_other_var equals 5 or 7 does not exit For and continues to other_commands. This is known behavior, am i missing something? Or there is something else in my huge program?
I've replaced Exit with Return cause no need to stay in Sub after the condition in Select block is true, and all returned to normal.