Repeat and Edit Commands in the Excel VBA Immediate Window
Question details
The user wants to repeat and edit a previously entered command in the 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.
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.
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.
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.
Click in the Immediate Window and press the Up Arrow to move through earlier lines, or click the command directly with the mouse.
Place the insertion point on the command line and use the keyboard to change the statement as needed.
With the insertion point on the edited command line, press Enter to execute it again.

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.

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.




