|

A List of the Excel Visual Basic Editor Shortcut Keys

While you can pick these Shortcut Keys up from the menus in the Excel Visual Basic Editor, it is useful to have them all in one place.

F1                         Help on the highlighted item
F2                         Object Browser
Shift+F2               View Definition (Go to highlighted Sub or Function)
F3                         Repeat last Find
F4                         Display Properties Window
F5                         Run / Continue Run
F8                         Single Step (in Break Mode)
Shift+F8               Step Over (run called procedures, step current procedure)
Ctrl+F8                 Run to Cursor
F9                         Set / Remove Breakpoint in code (or click grey margin)
Shift+F9               Quick Watchpoint (in Break Mode)
Ctrl+F9                 Set Current Statement (in Break Mode) (or drag yellow arrow)
Alt+F11                 Swap between Excel and Visual Basic Editor
Ctrl+Break            Enter Break Mode
Ctrl+F                   Find
Ctrl+H                   Search and Replace (details below)
Ctrl+G                  Display Immediate (Debug) Window (most useful in Break Mode)
Ctrl+R                   Display Project Window
Ctrl+J                   List members (properties and methods) of Object
Ctrl+C                   Copy selection
Ctrl+X                   Cut selection
Ctrl+V                   Paste at cursor
Ctrl+A                   Select All
Ctrl+S                   Save Excel File and Macros
Tab                       Indent selected Block
Shift+Tab             Outdent selected Block
Double-Click word     Select Word
Drag in unselected text                  Select Text
Drag selected text Move Text
Ctrl+Drag selected text                 Copy Text

1.        Find and Replace

Tip: Edit > Replace (Ctrl+H) can rapidly replace code with other code.  Note the “Search” options to set the scope of the search:

The scope lets you search the current procedure (sub or function), module, or project.  Or, if you selected text spanning more than one line, the selected text.

Note the direction: Sometimes you may want to search up rather than down.  “Down” is also the direction for “All”.  However, “All” continues at the beginning of the scope once it reaches the end.

With the “Use Pattern Matching” option, you can use wildcards in your search.  Patterns you can use are:

  • * matches any number of any characters.
  • ? matches any single character.
  • # matches any single numeric digit.
  • [m-n] matches any single character from m to n.

Example: [A-Z][0-9] matches any one letter followed by any one number.  Whereas  ?# matches any one character (including spaces, punctuation, and special characters) followed by any one number.

Literal characters match those characters.  Thus sub*# will match the letters “Sub” followed by a number somewhere on the same line.  Notice that turning on “Use Pattern Matching” turns the “Match Case” option off.  Pattern Matching is always case insensitive.

If you go out of the Visual Basic Editor (but not Excel itself) the Find and Replace dialog box remembers your previous search.  Check that those options are still the ones you want!

Similar Posts