Please Note: This article is written for users of the following Microsoft Excel versions: 2007, 2010, and 2013. 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

by Allen Wyatt
(last updated September 12, 2015)

3

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.)

ExcelTips is your source for cost-effective Microsoft Excel training. This tip (10922) applies to Microsoft Excel 2007, 2010, and 2013. 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

Opening Works Documents in Word

When you change the word processing software you are using, you often need to worry about converting your old documents to ...

Discover More

Moving Master and Subdocuments

If you need to move master documents or subdocuments from one place to another on your computer, you have to keep in mind the ...

Discover More

Adding an Image to a Document

They say that a picture is worth a thousand words, so it is fortunate that Docs allows you to easily add images to your ...

Discover More

Solve Real Business Problems Master business modeling and analysis techniques with Excel and transform data into bottom-line results. This hands-on, scenario-focused guide shows you how to use the latest Excel tools to integrate data from multiple tables. Check out Microsoft Excel 2013 Data Analysis and Business Modeling today!

More ExcelTips (ribbon)

Setting the Width for Row Labels

Excel displays, by default, a row label or heading at the left side of each row on the screen. As you scroll down the screen, ...

Discover More

Saving Movement on Enter with a Workbook

Press Enter when working in a workbook and Excel moves to a cell adjacent to the one in which you were working. If you want, ...

Discover More

Thoughts and Ideas on Significant Digits in Excel

Ruminations and reflections about significant digits in Excel. Includes examples of how significant digits can affect the ...

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}] 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 4 + 2?

2015-09-16 12:46:49

Sandy

Thank you! I have continually had the same problem and have been tempted to mutilate my keyboard by physically removing the F1 key!


2015-09-12 06:18:56

Steve Jezard

Create the entry below in the This Workbook module of the VBA window

Private Sub Workbook_Open()
Application.OnKey "{F1}", "mymail"
End Sub

Private Sub Workbook_BeforeClose(CANCEL As Boolean)
Application.OnKey "{F1}"
End Sub

then create a new module & enter this code

Private Sub myemail()
ActiveCell.Value = "myemailaddress@me.com"
End Sub

Now when you open the file & you press F1 myemailaddress@me.com will be entered into the active cell.

Good luck

Steve


2015-09-12 05:29:15

Gary

Thank you for this tip, it's very interesting.

Is there a way to assign a regularly used text string or action to the disabled F1 key?

For example making the F1 key run a macro or insert myemailaddress@me.com into a cell?

Thanks.


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.