In this blog post, you will learn about the use of “Immediate Window” in Excel VBA.
An immediate window is an excellent tool for VBA users. It can alone execute many queries and run macros without creating it and get the result immediately.
This tool can execute many queries and task, such as:-
Summing a value, creating and renaming sheets, change cell color, changing or renaming a cell value, and many more.
To find Immediate Window, Go to the Developer tab and then go to the “View” tab and click on “Immediate window” or press Ctrl + G as a keyboard shortcut.
Executing Simple Mathematics Quires
In Immediate Window, we can write simple questions such as see below:-
Type
these questions in the Immediate Window by initiating “?” (Question mark) and
type your query as we did in the below image.
? 5 + 3 and hit enter, it will show the answer like 8.
Count of Total Worksheets in a Workbook
We can execute a query about the total worksheet count in a workbook.
See in the image below:-
We can run the query as follows:-
An Immediate Window will respond immediately with the answer. See the above image for the result.
Changing or Renaming Cell Value by Immediate Window
Here in the
below list, we have weekdays name, see below:-
If we want to make changes in the above list by changing any cell value or inserting a value in a blank cell, just put the VBA code in the Immediate Window for quick results.
We can change these cell values with Immediate Widow at no time without creating a macro for this.
- First code, we change the existing cell value from “Wednesday” to Excelnsg.
- The second code put the value in a blank cell, Cell A10 with Month.
- Third code, we ask a question about the cell value as
And,
got the answer as Saturday.
Similarly, we can remove or clear the cell value from the given list.
So, here we have applied multiple tasks to execute the VBA code in the immediate window.
Not only these tasks, but we can also run multiple VBA codes to test with the help of an Immediate window.
Thanks
Narendra