Excel: Calling Macros As Subroutines

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 "ref" 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 "Finance".

  4. =Finance!Future() will cause the macro to branch to the macro named "Future" on the macro sheet named "Finance".

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 "Microsoft Excel Functions and Macros" version 2.2 manual.

More information on the RUN(reference) command, see page 271 of the "Microsoft Excel Functions and Macros" version 2.2 manual.


KBCategory: kbother
KBSubcategory:

Additional reference words: 1.00 1.03 1.04 1.06 1.50 2.20


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: November 2, 1994
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.