
- EXCEL SHORTCUT KEYS HOW TO
- EXCEL SHORTCUT KEYS CODE
- EXCEL SHORTCUT KEYS DOWNLOAD
With this method, keyboard shortcuts are really easy to set up and can be a little more appealing to people who might be intimidated by writing code. Let's look at some of the advantages and disadvantages for each method. Pros & Cons for Each Methodįor both methods, the keyboard shortcut can be used on any file we have open in Excel, as long as the file that contains the macros remains open. EXCEL SHORTCUT KEYS HOW TO
Checkout this article on how to create your own Personal Macro Workbook if you don't have yours setup yet. If your macros are stored in your Personal Macro Workbook, you can follow the same procedure as above. Just choose BeforeClose in the drop-down on the right and call the same macro. You can also add an event to delete the macro anytime you close the workbook.
EXCEL SHORTCUT KEYS CODE
In our case, the code would read “Call Module1.CreateShortcut” (without the quotation marks). Add a line of code to call the macro that you've created.
That will add the Workbook_Open event. In the VB Editor, double-click on ThisWorkbook in the Project Window. Here are instructions on how to set it up (see the video above for more details). However, you can actually automate this by using the Workbook_Open and Workbook_BeforeClose events. This allows you to setup different shortcuts for different macros all at the same time. For example, if we were using Ctrl+ C instead, the keyboard shortcut would revert back to performing the Copy action when Ctrl+ C is pressed.īoth the Create and Delete macros can have multiple lines of code with the OnKey method. This also resets the key combination to any native Excel keyboard shortcuts. The absence of a procedure tells Excel not to assign an action to that combination of keyboard strokes. Instead of “CreateShortcut” we will call it “DeleteShortcut” and we remove the procedure name (“CellColorGreen”) from the code. I've typed it just below the section for creating the shortcut. In this case, we want the key combination to run the macro called “CellColorGreen”.Īs you can also see in the image above, the code to delete this process is simple. Following this code, you are going to name the procedure that you want to assign to that combination of keys. How are you supposed to know the code for each key? Microsoft has this helpful document, which contains a complete list. The + is the code for Ctrl, the ^ is code for Shift, and the C key is enclosed in curly brackets (or braces). In my example I use “+^” for the Key parameter.
The Procedure is the name of the macro that will be called when the key combination is pressed.īoth parameters are enclosed in quotation marks. The Key is the keyboard shortcut combination represented by key codes. The Application.OnKey method has two parameters for the Key and Procedure.
Add a new line and start it with the command Application.OnKey followed by a space. Create a new macro and name it CreateShortcut (or whatever you choose to name the procedure),. In the VB editor, we are going to write some simple code to assign a macro to a keyboard shortcut. You can do this by clicking the Visual Basic button on the Developer tab, or pressing Alt+ F11. It also gives us more options and flexibility with our keyboard shortcuts. The Application.OnKey method allows us to create and delete the shortcuts. We can also use VBA code to create shortcut keys for macros. To delete the shortcut, simply repeat the process for accessing the Macro Options Window and then delete the character that you entered to create the shortcut. One way to avoid doing this is by adding Shift to the shortcut to make it a bit more complex. In the Macro Options Window, you can create the shortcut you want by adding a letter, number, or symbol.īe careful not to override an existing shortcut that you frequently use, such as Ctrl+ C to copy. After selecting the macro that you want to assign the shortcut to, click the Options button. (If you don't see the Developer tab on your ribbon, you can add it using these instructions.) Alternatively, you can use the keyboard shortcut Alt+ F8. Start by going to the Developer tab and clicking on the Macros button.
Here are the instructions on how to set it up.
We can use the Macro Options window in Excel to create a shortcut key to call the macro. I also explain the pros & cons of each method. These include the Macro Options window and VBA code for the Application.OnKey method. In this post we look at two popular ways to create the shortcut keys. This is especially true if you have to perform the same actions repeatedly.
EXCEL SHORTCUT KEYS DOWNLOAD
Assign-Keyboard-Shortcut-to-Macro.zip Download Create Your Own Keyboard Shortcuts to Run MacrosĪssigning keyboard shortcuts to simple or complex macros can help you work faster in Excel.