Please Note: This article is written for users of the following Microsoft Excel versions: 2007, 2010, 2013, 2016, 2019, and Excel in Microsoft 365. If you are using an earlier version (Excel 2003 or earlier), this tip may not work for you. For a version of this tip written specifically for earlier versions of Excel, click here: Disabling a Function Key.

Disabling a Function Key

Written by Allen Wyatt (last updated July 31, 2021)
This tip applies to Excel 2007, 2010, 2013, 2016, 2019, and Excel in Microsoft 365


1

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:

If you would like to know how to use the macros described on this page (or on any other page on the ExcelTips sites), I've prepared a special page that includes helpful information. Click here to open that special page in a new browser tab.

ExcelTips is your source for cost-effective Microsoft Excel training. This tip (10922) applies to Microsoft Excel 2007, 2010, 2013, 2016, 2019, and Excel in Microsoft 365. You can find a version of this tip for the older menu interface of Excel here: Disabling a Function Key.

Author Bio

Allen Wyatt

With more than 50 non-fiction books and numerous magazine articles to his credit, Allen Wyatt is an internationally recognized author. He is president of Sharon Parq Associates, a computer and publishing services company. ...

MORE FROM ALLEN

Improper Index Page Numbers

Adding an index to a document can be a nice finishing touch, particularly if the document is a long one. What happens if ...

Discover More

Setting Web Fonts

Is your worksheet information destined for a Web page? Here's how you can specify the fonts that should be used when ...

Discover More

Rotating Fractions in a Text Box

Rotating graphics in Word is not always straight-forward, but it can be done. This tip examines a special need to ...

Discover More

Program Successfully in Excel! John Walkenbach's name is synonymous with excellence in deciphering complex technical topics. With this comprehensive guide, "Mr. Spreadsheet" shows how to maximize your Excel experience using professional spreadsheet application development tips from his own personal bookshelf. Check out Excel 2013 Power Programming with VBA today!

More ExcelTips (ribbon)

Accessing Stock Information

Do you follow the stock market? If you do and you want to get stock information into a worksheet, there are some new ways ...

Discover More

F4 No Longer Changes Cell References

Excel has a wide variety of keyboard shortcuts that can help make it easier to use the program. When one of those ...

Discover More

Jumping to the Real Last Cell

Jumping to the last cell in a worksheet should be easy, but you may not always get the results that you expect. This tip ...

Discover More
Subscribe

FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."

View most recent newsletter.

Comments

If you would like to add an image to your comment (not an avatar, but an image to help in making the point of your comment), include the characters [{fig}] (all 7 characters, in the sequence shown) in your comment text. You’ll be prompted to upload your image when you submit the comment. Maximum image size is 6Mpixels. Images larger than 600px wide or 1000px tall will be reduced. Up to three images may be included in a comment. All images are subject to review. Commenting privileges may be curtailed if inappropriate images are posted.

What is 8 - 5?

2021-07-31 06:13:35

Rohn S, MVP 2012-2018

I've been using this macro to suppress F1. I keep hitting it accidentally when I'm aiming at F2.
.
I've tweaked the macro to add a message box remininding me that the Help key is blocked.
.
MsgBox ("F1 blocked In Personal.XLSB.Auto_Open")


This Site

Got a version of Excel that uses the ribbon interface (Excel 2007 or later)? This site is for you! If you use an earlier version of Excel, visit our ExcelTips site focusing on the menu interface.

Newest Tips
Subscribe

FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."

(Your e-mail address is not shared with anyone, ever.)

View the most recent newsletter.