Forum Discussion
robert2385
Aug 09, 2022Copper Contributor
shortcut keys
must all macro shortcut keys start with Ctrl in Excel?
robert2385
Aug 10, 2022Copper Contributor
Thank you NikolinoDE for your quick response. I am recording macros in Excel but want to avoid using Ctrl + (something) as this is used for so many existing shortcuts. When I have finished recording a macro and want to assign a shortcut this seems to be the only option. For example, the spreadsheet I am working on I have imported from an Open Office spreadsheet in which I used the shortcut, / + spacebar. This was very convenient. I wanted to use this in the Excel spreadsheet but it doesn't seem possible.
NikolinoDE
Aug 10, 2022Gold Contributor
We can use the OnKey method to define a keyboard shortcut. We define the key combination and the macro to be executed.
For example, the percent sign % represents the ALT key.
For more keyboard shortcuts, see the Excel developer reference for the Application.OnKey method.
Here is the code for the CTRL+ENTER key combination in VBA ^~ .
You can specify any key combination including SHIFT, CTRL, and ALT.
I know I don't know anything (Socrates)
- robert2385Aug 15, 2022Copper Contributor
NikolinoDE Thank you again for your help. I had hoped to avoid getting into VBA but I shall take a look at how the macro appears in VBA and see if I can modify it.