Illegal EXIT <EXIT type>
You used an Exit statement of a particular type outside a block statement of that type. The six types of Exit statement, and the block statements where each can appear, are as follows:
- Exit Do can appear only within a Do statement
- Exit For can appear only within a For statement
- Exit ForAll can appear only within a ForAll statement
- Exit Function can appear only within a Function statement
- Exit Sub can appear only within a Sub statement
- Exit Property can appear only within a Property Get statement or a Property Set statement
If the Exit statement is unintended, remove it.
If the Exit statement has the correct type but is misplaced, relocate it to within the intended block of that type.
If the Exit statement is in the intended place within a block but has the wrong type, change its type to the type of that block.