Excel: ADD.MENU Command Returns Error Message

Last reviewed: November 3, 1994
Article ID: Q78447

SUMMARY

The error message "Cannot find Macro" or "Error in Formula" results when a custom command is chosen from a custom menu in Microsoft Excel if both of the following occur:

  1. The macro that the custom command calls is included in the menu/command definition as an external reference (for example, "678.XLM!Test")

  2. The filename in the external reference begins with a number, such as the filename 678.XLM.

MORE INFORMATION

Steps to Reproduce Problem

  1. Enter the following into a macro sheet and save the file as 678.XLM.

          A1: Menus                B1: Newmenu         C1:
          A2: =ADD.MENU(1,B1:C2)   B2: Newcommand      C2: 678.XLM!HELLO
          A3: =RETURN()
          A4:
          A5: HELLO
          A6: =ALERT("HELLO",1)
          A7: =RETURN()
    
    

  2. Select cell A5.

  3. From the Formula menu, choose Define Name. Select the Command option and choose OK.

  4. Select cell A1. From the Macro menu, choose Run. The Newmenu menu should now appear.

  5. From Newmenu, choose Newcommand.

In Excel 3.0, the error message "Cannot find Macro" will occur and the macro "HELLO" will not run. In Excel 2.1, the error message "Error in formula" will occur and the macro "HELLO" will not run.

Workaround

When a worksheet name begins with a number, the filename must be enclosed in single quotes if it is to be used when referring to an external reference.

To correct the problem above, change the macro reference in cell C2 to read

C2: '678.XLM'!HELLO

REFERENCES

"Microsoft Excel User's Guide," version 3.0, pages 641-649


KBCategory: kbother
KBSubcategory:

Additional reference words: 2.10 2.1 2.10c 2.10d 2.20 2.2 2.21 3.00 2.1c
2.1d


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 3, 1994
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.