I want to use a Function Key to start a VBA

geno32080

Board Regular
Joined
Jan 23, 2020
Messages
107
Office Version
  1. 2013
Platform
  1. Windows
Good Morning Team Excel,
I have a spread sheet set up with command buttons to run different tasks, Is there a way to set function keys to trigger those command buttons? IE F2. The idea is to be able to navigate thru the sheet without using the mouse.
Thank you
 

Excel Facts

What is the fastest way to copy a formula?
If A2:A50000 contain data. Enter a formula in B2. Select B2. Double-click the Fill Handle and Excel will shoot the formula down to B50000.
Good Morning Team Excel,
I have a spread sheet set up with command buttons to run different tasks, Is there a way to set function keys to trigger those command buttons? IE F2. The idea is to be able to navigate thru the sheet without using the mouse.
Thank you
You can assign keyboard shortcut to a macro to run. But assigning a function key can cause some malfunctioning in the system as "F2" key is a pre-assigned key
 
Upvote 0
It is easy to use CTRL combinations for a macro, that's built in. Go to the Developer panel, Macros, select a VBA Sub name, then Options to set a CTRL shortcut.

But using function keys is going to require something much more complicated, I think. You would have to trap key press events, and look for those function keys then call the desired Sub from there. I'm not even sure you can capture functions keys. I've never done it and cannot find anything in a search to indicate what codes it would return.
 
Upvote 0

Forum statistics

Threads
1,215,709
Messages
6,126,391
Members
449,311
Latest member
accessbob

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
Back
Top