Disable F1 key

irchris

New Member
Joined
Nov 29, 2005
Messages
7
Does anyone know if it's possible to disable access to help via the f1 key, but still retain access to it on the drop down menus?
 

Excel Facts

Control Word Wrap
Press Alt+Enter to move to a new row in a cell. Lets you control where the words wrap.

Greg Truby

MrExcel MVP
Joined
Jun 19, 2002
Messages
10,022
Yes, using VBA you can. But why? That will annoy most users. Are you going to disable it on the main menu as well?
 

Russ At Index

Well-known Member
Joined
Sep 23, 2002
Messages
698
Office Version
  1. 365
  2. 2016
Platform
  1. Windows
  2. MacOS
Hi irchris,

Try this code................

Sub Workbook_Activate()
Application.OnKey "{F1}"
End Sub

HTH

Russ
 

Greg Truby

MrExcel MVP
Joined
Jun 19, 2002
Messages
10,022
Russ, close, but it would need to look like this:

<font face=Courier New><SPAN style="color:#00007F">Private</SPAN> <SPAN style="color:#00007F">Sub</SPAN> Workbook_Activate()
    Application.OnKey "{F1}", vbNullString
<SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">Sub</SPAN>

<SPAN style="color:#00007F">Private</SPAN> <SPAN style="color:#00007F">Sub</SPAN> Workbook_Deactivate()
    Application.OnKey "{F1}"
<SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">Sub</SPAN>
</FONT>

This assumes that irchris (a) knows how to get to the VBE and (b) how to get to the workbook's code page. Note that this is only his third post here.
 

irchris

New Member
Joined
Nov 29, 2005
Messages
7

ADVERTISEMENT

Thanks for the replies.

I guess I should clarify a bit. Sometimes when I go to hit the Esc key, but hit the f1 key instead. That results in the wait for help to come up. I find it very irritating when I'm trying to get work done.

I'm not so much looking to disable it in a specific workbook, but for any Excel file I bring up on my PC.

Oh yeah, I'm using Excel 2000.
 

Greg Truby

MrExcel MVP
Joined
Jun 19, 2002
Messages
10,022
In that case you'd want to add the following to your personal macro workbook. (See below if you are unfamiliar with this process.)

<font face=Courier New><SPAN style="color:#00007F">Private</SPAN> <SPAN style="color:#00007F">Sub</SPAN> Workbook_Open()
    Application.OnKey "{F1}", vbNullString
<SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">Sub</SPAN></FONT><hr />

To add code to a workbook:
  1. Alt+F11 to get to the Visual Basic Editor (VBE).
  2. From the VBE menu Insert|Module
  3. Add in code (copy and paste).
  4. Alt+F11 again to jump back to Excel.
  5. Alt+F8 then pick the macro from the list.
Note: It's usually a good idea to save your work before running new macros.<hr>If you wish to always have the macro available and not just when one particular workbook is open - i.e. the macro is a "generic" macro; it is better to place the macro in your Personal Macro Workbook. This is a workbook that Excel automatically creates. If you use the Macro Recorder to record a macro, the dialog box asks where you want to store the macro: (a) the active wb, (b) a new wb or (c) in your Personal Macro wb. If you select Personal Macro Workbook and you have not previously recorded a macro there, Excel will create it for you, naming it Personal.xls and placing it in your Excel startup directory. This way every time you start Excel, Personal.xls will load and its macros will be available to you. (Note that Personal.xls is a hidden workbook and not an Excel Add-In.)
 

Greg Truby

MrExcel MVP
Joined
Jun 19, 2002
Messages
10,022

ADVERTISEMENT

Meant to add this...

This code needs to go into the Workbook Code Module and not a Standard Module. In the VBE you should see a list of VB projects, including your personal macro workbook. If you do not, then hit Ctrl+R to activate the Project Explorer window. If it is collapsed, expand the item for your personal macro workbook. You should see a small XL icon and ThisWorkbook. Double click that to open the workbook code module. If you are in the correct spot, then the VBE's title bar should have "ThisWorkbook (Code)" in brackets at the end of the application title.

HTH
 

irchris

New Member
Joined
Nov 29, 2005
Messages
7
Greg and Russ,

Got the macro working on startup. I appreciate your help.

Thanks,
Chris
 

aequitas1903

Board Regular
Joined
Mar 8, 2012
Messages
127
Hey guys,

I tried this but i have to run the macro always when i open the excel.
is this possible to make it steady. I just dont want f1 in my excel life :)
 

Domski

Well-known Member
Joined
Jan 18, 2005
Messages
7,292
Did you put the code in your personal macro workbook as suggested?

Dom
 
Master Excel Bundle

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

Forum statistics

Threads
1,168,119
Messages
5,857,487
Members
431,882
Latest member
saaaaaaaaaaaaaaaaaaaaaa

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top