VBA – set a shorcut for VBA sub procedure (macro) in Excel

There are a few ways to set a shortcut for a macro. The easiest one is through the menu Developer> Macros > Options, select the macro and write the shortcut:

ShortCut

However, there is a better way to do this – with a code :

It is better, because with the code you can enable and disable the shortcut whenever you like. This is how the code looks like:

The first sub Generates a shortcut to the procedure “TestMe” with Ctrl+C. The second sub removes this shortcut. How do we know that the “^” sign stands for Ctrl? Well, we simply use google or the table below:

Table With VBA Shortcuts
Shortcut Sign
Shift +
Control ^
Alt %
F1 to F15 {F1} to {F15}
Left Arrow {Left}
Up Arrow {Up}
Escape {Escape}

Enjoy it 🙂

About

VBA Developer

Tagged with: