Home>Blogs>VBA>33 Useful VBA Shortcut Keys (Full List with Examples)
33 Useful VBA Shortcut Keys (Full List with Examples)
VBA

33 Useful VBA Shortcut Keys (Full List with Examples)

These 33 useful VBA shortcut keys help you write, test and debug macros faster and lay out UserForms in seconds instead of minutes. Below you will find all 33 in one table, grouped as in PK’s practice file (Ctrl keys, Alt keys, function keys and UserForm design keys), each explained with the example from the video.

33 useful VBA shortcut keys for UserForm alignment, sizing and spacing next to a sample VBA UserForm
The UserForm design shortcuts line up, resize and space text boxes in a couple of keystrokes.

⬇️  Download the VBA Shortcut Keys Sheet
ZIP (22 KB) · .xlsm with the shortcut list and demo macros · enable macros to try the examples

Watch the Video Tutorial

In the video PK demonstrates every shortcut live in the VBA editor, from Ctrl + Space on a worksheet variable to centring a title label on a UserForm.

What You Will Learn

  • 5 Ctrl shortcuts for IntelliSense, the Project Explorer, the Immediate window and moving between modules.
  • 3 Alt shortcuts to jump into the editor and insert modules and UserForms.
  • 6 function-key shortcuts to run, step through and debug code.
  • 19 UserForm shortcuts to align, resize, space and centre controls.

All 33 Useful VBA Shortcut Keys

A plus sign means hold the keys together. A comma means press the keys one after another: the Alt sequences open the editor’s menus by their underlined letters, so you press Alt, release it, then tap the letters.

# Shortcut What it does Menu command
With Ctrl
1 Ctrl + Space Auto complete the word you are typing Edit > Complete Word
2 Ctrl + J Show the IntelliSense list of properties and methods Edit > List Properties/Methods
3 Ctrl + R Show the Project Explorer View > Project Explorer
4 Ctrl + G Show the Immediate window View > Immediate Window
5 Ctrl + Tab Move between open modules and UserForms No menu item
With Alt
6 Alt + F11 Toggle between Excel and the Visual Basic Editor View > Microsoft Excel
7 Alt, I, M Insert a new module Insert > Module
8 Alt, I, U Insert a new UserForm Insert > UserForm
Function keys
9 F4 Show the Properties window View > Properties Window
10 F5 Run the current macro or UserForm Run > Run Sub/UserForm
11 F8 Run the code step by step Debug > Step Into
12 F9 Toggle a breakpoint on the current line Debug > Toggle Breakpoint
13 Ctrl + Shift + F9 Clear all breakpoints Debug > Clear All Breakpoints
14 Shift + F2 Jump to the procedure under the cursor View > Definition
UserForm design (select the controls first)
15 Alt, O, A, L Align left Format > Align > Lefts
16 Alt, O, A, C Align center Format > Align > Centers
17 Alt, O, A, R Align right Format > Align > Rights
18 Alt, O, A, T Align top Format > Align > Tops
19 Alt, O, A, M Align middle Format > Align > Middles
20 Alt, O, A, B Align bottom Format > Align > Bottoms
21 Alt, O, M, W Make same width Format > Make Same Size > Width
22 Alt, O, M, H Make same height Format > Make Same Size > Height
23 Alt, O, M, B Make same height and width Format > Make Same Size > Both
24 Alt, O, H, E Horizontal spacing: make equal Format > Horizontal Spacing > Make Equal
25 Alt, O, H, I Horizontal spacing: increase Format > Horizontal Spacing > Increase
26 Alt, O, H, D Horizontal spacing: decrease Format > Horizontal Spacing > Decrease
27 Alt, O, H, R Horizontal spacing: remove Format > Horizontal Spacing > Remove
28 Alt, O, V, E Vertical spacing: make equal Format > Vertical Spacing > Make Equal
29 Alt, O, V, I Vertical spacing: increase Format > Vertical Spacing > Increase
30 Alt, O, V, D Vertical spacing: decrease Format > Vertical Spacing > Decrease
31 Alt, O, V, R Vertical spacing: remove Format > Vertical Spacing > Remove
32 Alt, O, C, H Center in the form horizontally Format > Center in Form > Horizontally
33 Alt, O, C, V Center in the form vertically Format > Center in Form > Vertically

The menu command column is an addition for reference, checked against Microsoft’s VBA editor menu documentation. The shortcuts and descriptions come from PK’s practice file and video.

Ctrl Shortcuts: Write Code Faster

Ctrl + Space: auto complete

Start typing a word and press Ctrl + Space. If only one match exists, VBA completes it; otherwise it shows the matching list. In the video PK declares Dim sh As Worksheet, types sh.ra and presses Ctrl + Space, and VBA fills in Range because it is the only property that starts with ra.

Ctrl + J: IntelliSense list

Ctrl + J opens the drop-down list of properties and methods at the cursor.

Ctrl + R and Ctrl + G: Project Explorer and Immediate window

If the Project Explorer is missing, Ctrl + R brings it back so you can see every module and UserForm. Ctrl + G opens the Immediate window at the bottom. PK’s example sets x = 5, y = 6 and z = 7, pauses the code, then types this in the Immediate window:

?x+y

It prints 11. The question mark means print the result.

Ctrl + Tab: move between modules and UserForms

With several code windows open, Ctrl + Tab cycles through them, including UserForms.

Alt Shortcuts: Open the Editor and Insert Objects

Alt + F11 switches from Excel to the VBA editor and back again. Inside the editor, Alt, I, M inserts a new module (PK’s Module4 appears instantly in the demo) and Alt, I, U inserts a new UserForm. Both are Insert-menu sequences: Alt opens the menu bar, I opens Insert, and M or U picks the item.

Function Keys: Run and Debug Your Macros

F4 and F5: properties and run

Select a UserForm or control and press F4 to open its Properties window. Click inside a macro and press F5 to run it. PK’s demo macro from the practice file:

Sub VBA_Shortcut_Keys()





Dim sh As Worksheet





Set sh = ActiveSheet





Dim x, y, z As Integer





x = 5





y = 6





z = 7





MsgBox x + y + z





End Sub

Press F5 and the message box shows 18.

F8, F9 and Ctrl + Shift + F9: step through and breakpoints

F8 runs the code one line at a time; the yellow line shows what runs next. F9 puts a breakpoint on the line where the cursor is, so F5 runs until that line and stops. Press F5 again to continue to the next breakpoint. Ctrl + Shift + F9 removes every breakpoint at once.

Shift + F2: jump to a procedure

The practice file has a second macro that calls the first:

Sub test()





Call VBA_Shortcut_Keys





End Sub

Click on VBA_Shortcut_Keys inside test and press Shift + F2. The editor jumps straight to that procedure’s code, even when it lives in another module.

UserForm Shortcuts: Design Forms in Seconds

These 19 shortcuts all come from the editor’s Format menu (Alt, O). First select two or more controls on the UserForm (drag a box around them, or Ctrl + click), then press the sequence.

Align: Alt, O, A + L, C, R, T, M or B

PK selects several text boxes of different widths and presses Alt, O, A, L: they line up on the left. C, R, T, M and B align centres, rights, tops, middles and bottoms. The editor lines up the other controls with the one that has the white grab handles, the reference control.

Make same size: Alt, O, M + W, H or B

Alt, O, M, W gives the selected controls the same width, H the same height and B both. In the video PK makes them the same width first, then aligns them left.

Horizontal and vertical spacing: Alt, O, H or V + E, I, D or R

Alt, O, H, E makes the gaps between controls equal. I increases the gap evenly each time you press it, D decreases it and R removes it so the controls touch. Swap H for V for the same four commands on a vertical stack of controls.

Center in form: Alt, O, C + H or V

PK adds a title label and presses Alt, O, C, H to centre it horizontally on the form. Press it again after resizing the form. Alt, O, C, V centres vertically.

Bonus Shortcuts Worth Knowing

Addition, not in the original list. These come from Microsoft’s documentation of the VBA editor menus:

  • Ctrl + Shift + F2: go back to your last position after Shift + F2.
  • Shift + F8: step over a called procedure; Ctrl + Shift + F8: step out of it.
  • Ctrl + F8: run to the cursor.
  • Ctrl + Break: stop a running macro.

Common Errors & Fixes

  • The Alt, O shortcuts do nothing. Select the controls on the UserForm first, and make sure the form designer (not a code window) is active.
  • Alt + I + M held together does not work. Press the keys in sequence: Alt, then I, then M.
  • F5 runs the wrong macro or asks for a name. Click inside the procedure you want first. If the cursor is outside any procedure, VBA shows the macro list.
  • Alt + F11 does nothing on a laptop. The F keys may be media keys. Hold Fn as well, or switch the Fn lock.

Tips

  • Learn the menu letters, not the full sequence: A for Align, M for Make Same Size, H and V for spacing, C for Center.
  • Watch out in the demo line Dim x, y, z As Integer: only z is an Integer, while x and y are Variants. Write Dim x As Integer, y As Integer, z As Integer when every variable needs the type. (Addition.)
  • Microsoft documents the editor’s Debug menu commands and shortcuts, including breakpoints and stepping.

Want It Ready-Made?

If you would rather start from a finished, macro-ready workbook than build every tool yourself, browse the Excel VBA tools on NextGenTemplates.com.

Related Tutorials

Looking for ready-made Excel VBA Tools?
Browse finished, fully working templates you can use with your own data straight away.

FAQ

What is the shortcut to open the VBA editor in Excel?

Press Alt + F11. Press it again in the editor to go back to Excel.

How do I run VBA code line by line?

Click inside the macro and press F8. Each press runs the highlighted yellow line and moves to the next one.

How do I align controls on a VBA UserForm quickly?

Select the controls, then press Alt, O, A followed by L, C, R, T, M or B for left, center, right, top, middle or bottom.

Why does Ctrl + Space not complete my code?

It completes only when a single match exists. With several matches it shows the list, so type more letters or pick from the list.

About the Author

PK is a Microsoft Excel expert and trainer and the founder of PK: An Excel Expert and NextGenTemplates.com. He has been teaching Excel, VBA and Power BI since 2016 on his YouTube channel.

Conclusion

These 33 useful VBA shortcut keys cover the whole workflow: Ctrl + Space and Ctrl + J while you write, F5, F8 and F9 while you test, and the Alt, O sequences that turn UserForm design from slow dragging into a few keystrokes. Download the practice file, open the editor with Alt + F11 and try each one on PK’s demo macro and UserForm.

PK
Meet PK, the founder of PK-AnExcelExpert.com! With over 15 years of experience in Data Visualization, Excel Automation, and dashboard creation. PK is a Microsoft Certified Professional who has a passion for all things in Excel. PK loves to explore new and innovative ways to use Excel and is always eager to share his knowledge with others. With an eye for detail and a commitment to excellence, PK has become a go-to expert in the world of Excel. Whether you're looking to create stunning visualizations or streamline your workflow with automation, PK has the skills and expertise to help you succeed. Join the many satisfied clients who have benefited from PK's services and see how he can take your Excel skills to the next level!
https://www.pk-anexcelexpert.com