Microsoft KB Archive/27341

{| = Excel: Calling Macros As Subroutines =
 * width="100%"|

Last reviewed: November 2, 1994

Article ID: Q27341

SUMMARY
The Microsoft Excel ref and ref(argument_1,argument_2,...) functions can be used to branch to another part of your macro sheet. The word &quot;ref&quot; in this formula is replaced by a cell reference or a named reference. The following are examples:


 * 1) =B1 will cause macro execution to branch to cell B1 on the current macro sheet.
 * 2) =B1(A10,A11,A12) will cause macro execution to branch to cell B1 on the current macro sheet with three arguments (A10, A11, and A12) being passed. Cells B2 through B4, which are the first cells in the macro being branched to, must contain the ARGUMENT function for each argument passed.
 * 3) =Finance!A1 will cause the macro to branch to cell A1 on the macro sheet called &quot;Finance&quot;.
 * 4) =Finance!Future will cause the macro to branch to the macro named &quot;Future&quot; on the macro sheet named &quot;Finance&quot;.

The RUN(reference) command can also be used to branch to a subroutine macro. However, using the RUN command does not allow arguments to be passed. More information on the ref and ref(argument_1,argument_2,...) commands can be found on page 191 of the &quot;Microsoft Excel Functions and Macros&quot; version 2.2 manual.

More information on the RUN(reference) command, see page 271 of the &quot;Microsoft Excel Functions and Macros&quot; version 2.2 manual.
 * }