How to assign a hotkey to a command button macro

billyheanue

Board Regular
Joined
Jul 13, 2015
Messages
109
Hi all,

I have code that starts with

Private Sub CommandButton3_Click()

and I am wondering how to go about assigning a hotkey to it instead of having to use the command button.

Any pointers?

thanks!
 

Excel Facts

Who is Mr Spreadsheet?
Author John Walkenbach was Mr Spreadsheet until his retirement in June 2019.
Hello,



  1. Hit the Record Macro Button in the Developer Tab
  2. Give the Macro a name and in the shortcut Key hit the key of your choice in the Keyboard to be used as hotkey and press ENTER
  3. Do a single action as selecting any cell
  4. Stop the macro recorder
  5. Go to the VBA Editor, and look for the new module just been created by Excel when recording the macro
  6. Replace the content of the macro by your code.

That would be it.
 
Upvote 0

Forum statistics

Threads
1,216,473
Messages
6,130,837
Members
449,597
Latest member
buikhanhsang

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