When pressing F1 key it forth to enable Help pane in excel. In some situations, we can press F1 to enable other actions from other applications, for example, for some tools we can via pressing F1 to capture screen directly. So, we can disable F1 key in some instances. This article will help you to know the method to disable F1 key in excel by VBA code.
1. Disable F1 Key with VBA Code in Excel
Click Help tab in ribbon, and move cursor floating on Help icon. You can see a tip pops up to indicate that F1 is the shortcut key for Microsoft Excel Help. Now let’s disable F1 key refer to below steps.
Step1: On current visible worksheet, right click on sheet name tab to load Sheet management menu. Select View Code, Microsoft Visual Basic for Applications window pops up.
Or you can enter Microsoft Visual Basic for Applications window via Developer->Visual Basic. You can also press Alt + F11 keys simultaneously to open it.
Step2: In Microsoft Visual Basic for Applications window, click Insert->Module, enter below code in Module1:
Sub disableF1()
Application.OnKey "{F1}", ""
End Sub
Step3: Save VBA code. And then quit Microsoft Visual Basic for Applications.
Step4: Try to click F1, verify that Help system is not loaded and displayed.
Comment:
- This method only takes into effective on Excel 2007/2010, it doesn’t work on upper versions.
- If you want to enable F1 again, enter below VBA code:
Sub enableF1()
Application.OnKey "{F1}"
End Sub