In Excel VBA you can assign a hot key for a command Button as well. It means you can assign a hot key to a command button which can be triggered by pressing that hot key from the keyboard. It means you can perform the operation either by clicking on the command button or by pressing the hot key.
For a command button you can assign a hot key by providing the key code in the Accelerator property of the command button. Accelerator property excepts a single key as an input from the keyboard. Hot key for a command button is always a combination of ALT key and the key entered by your choice.
Note: Interesting thing about setting a hot key (Accelerator property) for a command button is that you can easily find out the hot key associated for that command button, if your key (letter) exists in the caption of the command button. If key entered by you for a command button exists in the caption of the command button then automatically that letter from the caption get underlined. Refer the below image..
As highlighted in the above code, letter m is underlined because accelerator property is set to letter m, isn’t it interesting?? 🙂
Now after setting up this property as soon as you press ALT + m from the keyboard CommandButton1 will be triggered and all the statements will be executed which is written for that command button.
On your blog I always can read many interesting information. Linking to you should I use link text Learn Excel Macro
Assign a Hot Key to a Command Button in Excel?
can we assign F1 key as accelerator to a command button