Making Keyboard Shortcut

Making Keyboard Shortcut #

what is it? #

If you want to create a shortcut key to run an Excel macro, you can write the code as follows. The example below applies the shortcut key when the userform is launched.

sample #

You can set macro shortcut key with below:
% : shift, ^ : control, + : alt

Sub showMenu()
    MyMacros.Show

    'shift + alt + 1
    Application.OnKey "%+1", "lineGrayDblClick" 'macro name
    'shift + alt + 2
    Application.OnKey "%+2", "lineBlackDblClick"
    'shift + alt + 3
    Application.OnKey "%+3", "lineBlackBoldDblClick"
    'shift + alt + 4
    Application.OnKey "%+4", "colorFill"
End Sub

 
original post (Kor)