Using the Immediate Window in VBA

We all know that VBA allows us to create Macros in Microsoft Excel which does complex tasks in an easy way. You can create a Macro for tasks which you are supposed to do repeatedly. But, while writing VBA code we come across some issues or errors and finding them would be hard. So, we need to know the debug process to find such errors. Using Immediate Window in VBA helps us to know the value of the variable used in the code, hence making the debugging easy. Excel MVP Jordan shows us how to use Immediate Window in Excel VBA.

Using the Immediate Window in Excel VBA

1 – Enable Developer Tab in Excel

In order to open Visual Basic Editor in Excel, you need to enable the Developer tab in Excel. Next tap on the Developer tab and click on ‘Visual Basic’ option and it would open Visual Basic Editor.

2 – View the Immediate Window

To open Immediate Window, click on “View” tab and select “Immediate Window” option. You can even press “CTRL+G” to open Immediate Window.


3 – See Output in Immediate Window

Once you have enabled Immediate Window, then you can print output of any variable in it. You can execute the VBA program and it would show the output in Immediate Window. In this example, I used ‘Debug.Print’ which prints the value of ‘I’ in Immediate Window. You can explore more functions as such. It also possible to delete the text printed in Immediate Window.


4 – Directly Debug in Immediate Window

Not only you can print values present in the program, you can even directly check values by typing in Immediate Window. Let us say, you want to set the width of selected cell in Excel, then you can type “selection.columnWidth=10”. This would set selected cell width to the given value.


These are just examples and you can explore more by using different functions. There are lot more functions which you can use directly in Immediate Window. Please give it a try.

What’s next?

So, you can debug VBA Program using Immediate Window and get rid of the errors. Give it a try and explore it more.

Let us know how you are using Immediate Window to debug your VBA programs. If you have anything to add, please do share with us through comments.

Sridhar Belide


You may also like

April 23, 2014

A VBA Coding Manifesto (Part 1)

May 3, 2014

A VBA Coding Manitesto (Part 2)

December 22, 2013

Excel Holiday Card
  • {"email":"Email address invalid","url":"Website address invalid","required":"Required field missing"}

    Free 24 Excel Tips Guide

    Discover the secrets to Excel efficiency with our free guide: '24 Proven Microsoft Excel Tips to Help You Save Time'

    A humble gift from us to you, to make your Excel journey smoother and more productive. Grab your copy now and start mastering Excel like never before!