
In this article we will explain how to use the immediate access window in a VBA debugging environment. This environment can be used as a type of notepad or sandbox area and has many uses as well as debugging code.
If you don’t see the Immediate window, you just need to turn it on. It is very simple.
- Open the Visual Basic Editor.
- Look
- Immediate window
Or, if you're mad at the shortcuts, you can do the following:
- ALT + 11 to open the Visual Basic Editor
- CTRL + G to open the Immediate window and place the cursor there.
You are all set. At first glance, the window looks quite soft and simple, but in fact really useful for example
- Get some info about your current Excel Workbook.
We can ask questions in the Immediate window and wait for an answer, we just need to use a question mark. For example, typing in the window ? Worksheet.Count we correctly, for example, in my book of work stated that there are 4 sheets. Cool.
- Run the VBA code line and get immediate results.
You can also simply execute one piece of VBA code from the Immediate window. Just delete? right from the start of your application and the code will work. Let's take a look at an example. We can make all hidden worksheets visible by typing this code in the Immediate window.
For each ws In Sheets: ws.Visible = True: Next
This code snippet will go through all worksheets and set their visible property to TRUE. Great job! I hope this gives you the opportunity to feel the power of the immediate window.
- Run the macro from the immediate access window
So, as indicated at the beginning of this article, run the macro from the Immediate window. It's really simple, we just need to enter the name of the macro right in the Immediate window.
Here again, a macro that will hide all sheets in my book or make it visible (even if you prefer to say it!).
O called this macro Unhide_Multiple_worksheets.
All I need to do is type the name of the macro in the Immediate window, click Return and run the macro. Want to try another?
Other ways to run a macro
- Hit F5
- Click the "Run Command" button in the VB editor in Excel.

