Excel: Returning the Name of the Currently Running Macro SheetLast reviewed: November 2, 1994Article ID: Q59244 |
SUMMARYIn Microsoft Excel, you sometimes must get the name of the currently running macro sheet. This is necessary, for example, if you want to activate a macro sheet whose name may have been changed since it was written. Because the argument to the ACTIVATE() command is a text string, it is not changed when the document name is changed. To get the name of the currently running macro sheet, enter the following three macro lines. Hold down the COMMAND key when entering the second line so that it is entered as an array formula. If it is correctly entered as an array, Excel places braces ({}) at the beginning and end of the formula.
=SET.NAME("flag","run") =LOOKUP("\",IF(ISERROR(GET.DEF("""run""",DOCUMENTS())),,DOCUMENTS())) =DELETE.NAME("flag") MORE INFORMATIONThe formula works by setting a name on the active macro sheet in the first line, then going through all the open worksheets looking for that definition in the second line, as follows:
|
KBCategory: kbmacro
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |