by Allen Wyatt
(last updated August 9, 2016)
Inna notes that Excel allows her to assign shortcut keys to my macros. However, it looks like the shortcuts will only work if they refer to a macro in an open workbook. She usually has her macros stored in a separate workbook. If a macro is assigned to a toolbar button (or an option on the Quick Access toolbar), the workbook containing the macro is automatically opened so it can be run. This does not happen if Inna uses a keyboard shortcut for the same macro; pressing the shortcut won't load the workbook that contains the macro. She wonders if there is a way around this.
This problem is caused by the fact that Excel stores a fully qualified path to a macro as part of its toolbar info (that means it includes the name of the workbook in which the macro is stored), but it doesn't with the shortcut key info—that only has the macro name itself. This means that a shortcut doesn't know how to find a macro unless it is in a workbook that is open.
The easiest way around the problem would be to move the macros to the Personal.xlsm (or, in older versions of Excel, Personal.xls) workbook. This workbook is loaded automatically loaded when Excel is started, so the macros would always be available and the shortcut keys always work. Detailed information on the workbook can be found here:
Of course, you can bypass the Personal.xlsm approach by simply moving the workbook containing the macros to the Startup folder used by Excel. Anything in the folder is automatically opened when you first start Excel, which means that the macros in those workbooks would also be accessible.
The workbook containing your macros could also be compiled into an Excel add-in, which would be available at all times. (How you create and use an add-in has been covered in other ExcelTips.)
ExcelTips is your source for cost-effective Microsoft Excel training. This tip (6401) applies to Microsoft Excel 97, 2000, 2002, and 2003.
Comprehensive VBA Guide Visual Basic for Applications (VBA) is the language used for writing macros in all Office programs. This complete guide shows both professionals and novices how to master VBA in order to customize the entire Office suite for their needs. Check out Mastering VBA for Office 2010 today!
Macros are often used to process the data stored in a worksheet. Some of these processing needs can be pretty specific to ...Discover More
The security features built into Excel 2002 and 2003 allow you to digitally sign your macros so that users can rest ...Discover More
Want to get some input from the users of your workbooks? You can do it by using the InputBox function in a macro.Discover More
Got a version of Excel that uses the menu interface (Excel 97, Excel 2000, Excel 2002, or Excel 2003)? This site is for you! If you use a later version of Excel, visit our ExcelTips site focusing on the ribbon interface.