Clear Excel VBA Immediate Window Manually

There is no explicit option to clear immediate window.

Just select all content in Immediate window using control + A, then press delete button.

This is the only option to clear the data in this window.

Excel VBA Code to Clear Immediate Window

As we saw early there is no explicit option, we have to automate the manual actions explained above.

So, either You have to flush the content with many entries or use send keys.

Here is the code snippets that does this.

Sub Clear_Immediate_Window()
    'Method 1
    Debug.Print String(65535, vbCr)
    
    'Method 2
    Application.VBE.Windows("Immediate").SetFocus
    Application.SendKeys "^a {DEL} {HOME}"
End Sub

Usually, we use immediate window to print debug messages using debug.print statements. But, this will look messy if there are too many print statements.

When a new execution starts, the older messages does not get cleared automatically.

So, we have to follow the above steps do perform this action.