Search This Blog

Tuesday, June 23, 2009

Legacy VBA Error - For next loop may really mean If end if.

I was updating some legacy VBA code today and had to add some additional logic to a function. When I click the run button, I was faced with this dialog box
A quick check of the code indicates that there IS a closing "NEXT" statement for the "For Each..." loop. When this happens to you, check any "If...." logic constructs within the "For ... Next" loop. Chances are you'll find a missing "End if" statement.

No comments: