Get Details in Excel VBA Code

Did you ever get an Excel file from someone else, and try to sort out their Excel VBA code? Or, even worse, open an Excel file that you wrote long ago, and try to remember what all those variables mean?

I spend lots of time staring at Excel code, but apparently I don’t use the right-click menu too often, because I hadn’t noticed a couple of handy commands until recently.

These commands can help you decipher that mysterious code, and unravel the complicated sections.

Excel VBA Quick Info

The first handy command is Quick Info. I have Auto Quick Info turned on in the VBE Editor options, and it helps me remember the syntax as I type the code.

excelvbainfo00

Right-Click for Quick Info

What I didn’t realize was that you can right-click on a variable, function, statement, method, or procedure in the code, and click Quick Info.

Right-Click for Quick Info in Excel Visual Basic Editor
Right-Click for Quick Info in Excel Visual Basic Editor

A tooltip appears, with details on the selected item.

excelvbainfo02

Excel VBA Definition

The other right-click command that I finally discovered is the Definition command.

excelvbainfo03

Click the Definition command, and it takes you to the selected variable’s definition.

Finding the definition is easy in most procedures, but in a long procedure, with a long list of variables, the Definition command really makes the job easier.

It’s especially helpful if the variable is defined on a different code module!

excelvbainfo04
___________

0 thoughts on “Get Details in Excel VBA Code”

  1. If you prefer the keyboard:
    Ctrl+I shows the Quick Info
    Shirt+F2 gets you to the definition and
    Ctrl+Shift+F2 gets you back to the codeline

    Regards,
    Dominik.

  2. I definitely like the Quick Info tip, I had not used that option before. However For the Definition Command, that’s equivalent to the keyboard shortcut I use all the time: Shift-F2. This will jump to to the definition of the variable, and then you can press CTRL-SHIFT-F2 to return back to where you were. Very handy!

  3. Just so your reader’s know, Definition does not only work for variables… you can use it for functions and subroutines as well. Just put the text cursor on a function name or subroutine call, activate Definition and you will be taken to the first line of the function or subroutine.

  4. Good post, great discussion. I learned two things that will help me. 1) the Ctrl+I shortcut for Quick Info, and 2) that after using the Shift+F2 to find the first line of a function or subroutine, you can use Ctrl+Shift+F2 to return to your starting point, even if it’s in another module.

Leave a Reply to Anonymous Cancel reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.