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:
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:
|
1 2 3 4 5 6 7 |
Sub GenerateShortCut() Application.OnKey "^c", "TestMe" End Sub Sub RemoveShortCut() Application.OnKey "^c", "" End Sub |
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:
| Shortcut | Sign | |
|---|---|---|
| Shift | + | |
| Control | ^ | |
| Alt | % | |
| F1 to F15 | {F1} to {F15} | |
| Left Arrow | {Left} | |
| Up Arrow | {Up} | |
| Escape | {Escape} |
Enjoy it 🙂

