Hot keys for a command button in UserForm in Excel programming
you need to set the Accelerator in the Properties for the Command Button
I think you can only have upper case letters or numbers (not tested
Press Alt and the Accelerator Key to activate the Button.
From the VBA Help:
A single character used as a shortcut for selecting an object. Pressing the
ALT key, followed by the accelerator key gives focus to the object and
initiates one or more events associated with the object. The specific event
or events initiated varies from one object to another. If code is associated
with an event, it is processed when the event is initiated. Also called
keyboard accelerator, shortcut key, keyboard shortcut.
To designate an accelerator key, enter a single character for the
Accelerator property. You can set Accelerator in the control's property
sheet or in code. If the value of this property contains more than one
character, the first character in the string becomes the value of
When an accelerator key is used, there is no visual feedback (other than
focus) to indicate that the control initiated the Click event. For example,
if the accelerator key applies to a CommandButton, the user will not see the
button pressed in the interface. The button receives the focus, however,
when the user presses the accelerator key.
If the accelerator applies to a Label, the control following the Label in
the tab order, rather than the Label itself, receives the focus.
> Hi all,
> I want to assign a hot key (Like ctrl+h) to a command button in VBA
> On pressing that hot key i want to show some extra controls ont he
> How can assign hot key like that??