BREAK Command May Not Interrupt a Macro Loop in ExcelLast reviewed: November 2, 1994Article ID: Q76357 |
SUMMARYThe BREAK command is designed to interrupt a FOR-NEXT, FOR.CELL-NEXT, or a WHILE-NEXT loop. However, BREAK does not interrupt a macro loop if it is placed within a block IF statement.
MORE INFORMATION
Excel 3.0There are two forms of the IF function (Form 1 and Form 2). Form 2 is a block structure and can only be used on macro sheets. This form allows you to execute more than one statement based on the outcome of the IF statement's logical test. If a BREAK statement is encountered within a loop, that loop is terminated and the macro proceeds to the statement following the NEXT statement. If the BREAK command is encountered within a Form 2 IF function, the BREAK command will be ignored and the macro will enter an infinite loop. The BREAK command executes properly if encountered in a Form 1 (single-line) IF statement.
WorkaroundUse a Form 1 IF command in place of the Form 2 IF command.
Steps to Reproduce Behavior
REFERENCES"Microsoft Excel Function Reference," version 3.0, pages 22, 125-127
|
KBCategory: kbother
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |