top of page
John

How do YOU clear the Immediate window in the VBE?

Updated: Aug 22

Maybe you press Ctrl+G, then Ctrl+A, then delete, then F7. Can you always remember all of those keys? Ever missed out the Ctrl+G and deleted a whole Module's worth of code?


Maybe you click in it with the mouse then select all the text then right click and select Cut then click back into the code window again with the mouse. Fiddly.


I'll tell you how I clear the Immediate window. I press Ctrl+Shift+C. That's it. That's the keyboard shortcut that, by default, VBE_Extras allocates to clearing the Immediate window. Though you can change the actual keys to whatever you want. And, by the way, you can also use Ctrl+Shift+S to scroll up to the start of the Immediate window ... and you can also use Ctrl+Shift+E to scroll down to the end of the Immediate window (and you can change those keys also).


Hold on though. Even better than that, I don't often use Ctrl+Shift+C because, typically, you want to clear the Immediate window before running some code that is going to Debug.Print more stuff there and, if the Immediate window already has content in it and the cursor position is not at the end of it, then your new info gets printed wherever the cursor happens to be, resulting in gibberish.


The better solution is to use one of the VBE_Extras commands that automatically clears (or scrolls to the end of) the Immediate window when you are running code:

  1. VBE_Extras will listen for the F5 key being pressed and for the 'Run Sub' menu item (i.e. in the VBE's built-in menu) being selected and clear / scroll-to-the-end-of the Immediate window

  2. VBE_Extras will listen for the F8 key being pressed and for the 'Step Into' menu item (i.e. in the VBE's built-in menu) being selected and clear / scroll-to-the-end-of the Immediate window

  3. VBE_Extras will 'Run again' * (by default using F10) the Sub you previously ran and clear / scroll-to-the-end-of the Immediate window ... if you are editing code in one place but want to run a Sub in another place, you don't have to navigate around your VBA project trying to find the Sub, you can run it from anywhere

  4. VBE_Extras has a 'Sub to run' * command which is similar to 'Run Again' but you can manually choose the Sub then Run it from anywhere (by default using F6)


'Run again' and 'Sub to run' are two of many commands provided by VBE_Extras ... check out what else it can do, and try it for free.


Alternatively, if you want to clear the Immediate window using VBA code, there are options to do this. Check out the Clear the Immediate Window Using Code post on Colin Riddington's "Isladogs on Access" site ... while the site is focused on Access, the code in this post will work in any VBA-enabled host application that is running on a Windows device.


* 'Run again' and 'Sub to run' are not available in Outlook.

0 comments

Comentarios


bottom of page