VBA Hover ToolTip Trick

September 14th, 2010 by datapig Leave a reply »

I’m pretty busy today so here’s a quick VBA tip.

We all know if you hover over a variable in VBA (while in debug mode) you can see the value of that variable.  This allows you to see the values that are being passed in and out of variables – very useful.  But by my estimation, these tooltips can only hold 77 characters (including the variable name).  This basically means if the value in your variable is too long, it gets cut off.

 

Here’s an example.  Hovering over the variable TempDataFile allows me to see the string that represents the file name, but that string gets cut off.

vbahover1

 

.

Although there is no way to tell Excel to show more than the first 77 characters, there is a trick you can use to see then last 77 characters.

Simply hold down the CTRL key while you hover.  As you can see, this allows me to see the last part of the file name.vbahover2

Advertisement

7 comments

  1. Rick Rothstein (MVP - Excel) says:

    Well, there is a new one on me. Up until now, I have always been executing (using your example variable name) a “?TempDataFile” statement in the Immediate Window. Thanks for posting this tip!

  2. How on earth did you uncover that little gem? Sticky keyboard key?

  3. Rick Rothstein (MVP - Excel) says:

    Interesting… and surprising… this trick also works in the compiled version of VB6. I was a VB MVP before becoming an Excel MVP… I used (and still do occasionally) the compiled version of VB6 for some 10 years now and I never have seen this trick before now. I wonder if it has always been available in the various versions of VB?

  4. AlexJ says:

    Used this three times today! Nice.

  5. Thank you for that interesting hint, that was new to me as well.
    Unfortunately, I discovered that even with the Ctrl key pressed, the tooltip just shows the text up to the 250th character of the string without appending an ellipsis at the end (O2k3).
    Thus, we still have to be cautious when debugging code with big strings.

    P.S.: I’m also curious how you discovered that! :)

  6. Happy Customer says:

    Nice tip, thanks! I also used the debug.print [variable name] method. This saves time!!

Trackbacks /
Pingbacks

  1. Office Links for September

Leave a Reply