Please Note: This article is written for users of the following Microsoft Excel versions: 97, 2000, 2002, and 2003. If you are using a later version (Excel 2007 or later), this tip may not work for you. For a version of this tip written specifically for later versions of Excel, click here: Disabling a Function Key.
Written by Allen Wyatt (last updated July 29, 2021)
This tip applies to Excel 97, 2000, 2002, and 2003
Jean asked if there is a way to disable the F1 key in Excel. It seems that she frequently presses F1 when she means to press F2, and doing so is bothersome.
The only way to disable a key such as this is to create a macro. The following macro will do the trick quite nicely:
Private Sub Workbook_Open() Application.OnKey "{F1}", "" End Sub
Private Sub Workbook_BeforeClose(CANCEL As Boolean) Application.OnKey "{F1}" End Sub
Actually, there are two macros here. The first one executes whenever the workbook is opened, and the second is executed when the workbook is closed. In the case of the first macro, the OnKey method traps every keypress of F1 and cancels it. The macro that runs when the workbook closes restores the normal operation of the F1 key.
These macros can be placed in a given workbook, in which case they will only apply while that workbook is open. If you want them to apply at all times when using Excel, store the macros in the Personal workbook. (The use of this workbook has been covered in other issues of ExcelTips. You can also find information on it in the Excel Help system which, ironically, is invoked by pressing the F1 key.)
Note:
ExcelTips is your source for cost-effective Microsoft Excel training. This tip (1990) applies to Microsoft Excel 97, 2000, 2002, and 2003. You can find a version of this tip for the ribbon interface of Excel (Excel 2007 and later) here: Disabling a Function Key.
Professional Development Guidance! Four world-class developers offer start-to-finish guidance for building powerful, robust, and secure applications with Excel. The authors show how to consistently make the right design decisions and make the most of Excel's powerful features. Check out Professional Excel Development today!
Want a quick way to speed up your macros? All you need to do is to stop Excel from updating the screen while the macro is ...
Discover MoreWhen your macro is humming along, minding its own business, a user watching the screen may not see any activity and ...
Discover MoreWhen creating an application in VBA for others to use, you might want a way for your VBA code to modify or delete other ...
Discover MoreFREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."
There are currently no comments for this tip. (Be the first to leave your comment—just use the simple form above!)
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.
FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."
Copyright © 2024 Sharon Parq Associates, Inc.
Comments