VBA & Macro Problems

Repeat and Edit Commands in the Excel VBA Immediate Window

Olivia MillerOlivia Miller Nov 20, 2026 870 views

Question details

The user wants to repeat and edit a previously entered command in the VBA Immediate Window.

Repeat and Edit Commands in the Excel VBA Immediate Window
Product
Microsoft Excel VBA editor
Device & OS
not provided
Scenario
Working in the VBA Immediate Window and needing to reuse an earlier statement.
Observed behavior
The user wants to navigate to an earlier command, revise it, and run it again.
Before you start

Open the workbook and the VBA editor, then display the Immediate Window from the View menu. Check that the command you want to reuse is still visible in the window.

Solution 1Recommended

Edit and rerun a previous Immediate Window command

Use this method to reuse a command that is still displayed in the Immediate Window.

The Up Arrow moves the insertion point through existing lines; it does not necessarily recall commands into a separate prompt as a command shell would. Output lines may appear between commands.

1
Open the Immediate Window

In Excel, open the VBA editor, then select View > Immediate Window. On Windows, you can press Alt+F11 to open the editor and Ctrl+G to show the window.

2
Find the previous command

Click in the Immediate Window and press the Up Arrow to move through earlier lines, or click the command directly with the mouse.

3
Edit the statement

Place the insertion point on the command line and use the keyboard to change the statement as needed.

4
Run the revised command

With the insertion point on the edited command line, press Enter to execute it again.

Edit and rerun a previous Immediate Window command
Check the line before running it: Make sure the insertion point is on the intended command rather than an output line. Running a statement again can change the workbook or the current VBA state.
Free Microsoft Office alternative

Work with Excel spreadsheets in WPS Office

WPS Office is a free, lightweight alternative for working with spreadsheets in a familiar interface. Open compatible Excel files to make the transition easier; it does not fix the Microsoft VBA Immediate Window.

Open and edit compatible Microsoft Excel XLS and XLSX files.Use a familiar spreadsheet interface for everyday workbook tasks.Work with spreadsheets in a lightweight office suite available for free.Move existing Excel files into WPS without starting your spreadsheets from scratch.
QA img-9

Frequently Asked Questions

How do I open the VBA Immediate Window?

Open the VBA editor in Excel and select View > Immediate Window. On Windows, Alt+F11 opens the editor and Ctrl+G displays the Immediate Window.

Does the Up Arrow recall commands like a command prompt?

The Up Arrow moves the insertion point through lines already displayed in the Immediate Window. You may need to navigate past output lines or click the earlier command directly.

Can I rerun a command without editing it?

Yes. Click the previous command line in the Immediate Window and press Enter. The statement runs again using the current VBA state.

What if the previous command is no longer visible?

If the command is no longer displayed in the Immediate Window, type it again in the window before pressing Enter.