Microsoft KB Archive/64174

Multiplan: Creating a Conditional Loop or Branch in a Macro PSS ID Number: Q64174 Article last modified on 07-25-1990 PSS database name: D_MPlan

2.01 3.00 3.01 3.02 3.04 4.00 4.01 4.20

MS-DOS

Summary:

A conditional loop and/or branch can be built into a macro using an IF macro command. The correct syntax for the IF command is as follows:

‘IF ’

If the condition is true, the macro will continue executing macro commands on the same line following the IF statement. If the condition is false, the macro will continue executing commands in the cell immediately below.

More Information:

The following macro demonstrates how a conditional loop and branch can be created using the IF macro command. The first line of the macro below is entered in R99C100:

‘ifr4c4>100’‘gor200c100’ ‘VAHello’r4c4’ ‘gor99c100’

If the condition is true (the value in R4C4 is greater than 100), the macro will jump to cell R200C100 and execute whatever commands are listed here. If R200C100 is empty, the macro will quit. If the condition is false (that is, R4C4 is 100 or less), the macro will execute commands in R100C100. The VA command in this cell asks you to enter a value and the macro provides the text “Hello” at the bottom of the screen. The value that you enter is immediately placed in R4C4. The macro proceeds to R101C100 where a GO command forces the macro to return to R99C100 to again evaluate the contents of R4C4 and branch appropriately.

Copyright Microsoft Corporation 1990.