You could greatly simplify your macro replacing the 'if' statement by a single 'Exit loop' with a constraint! It'll be easier to read and maintain in a more complex macro.I've made a macro template for you that will repeat the loop n times but if it is not finished and the condition is false it will stop the loop.