Code to clear Immediate window

JenniferMurphy

Well-known Member
Joined
Jul 23, 2011
Messages
2,553
Office Version
  1. 365
Platform
  1. Windows
I found this code that is supposed to clear the Immedite window.

VBA Code:
Sub ClearImmediateWindow()
Application.SendKeys "^g", True
Application.SendKeys "a", True
Application.SendKeys "{DEL}", True
End Sub

If I type "ClearImmediateWindow" in the Immediate window, it works. But if I call it from a UDF, it does nothing.
 
For the output to a text file on the hard drive (make sure to change the filename and its path to one of your choosing)...
VBA Code:
Sub TextOut(Txt As String)
  Open "c:\Temp\TestTestTest.txt" For Append As #1
    Print #1, Txt
  Close #1
End Sub

I got that to work. Excellent. Thank you.

1. Is there a way that I can get this Sub to open the destination folder in Windows Explorer?

2. Alternatively, is there a way that I can get the Sub to use the folder where the calling worbook in stored without having to pass that information?

3. How is this different from the OpenTextFile method?

4. I can see lots of uses for this. But I can't watch it as the code runs, like I can in the Immediate window. Do you know of code that I can use inside a UDF or Macro to clear the Immediate window?
 
Upvote 0

Excel Facts

VLOOKUP to Left?
Use =VLOOKUP(A2,CHOOSE({1,2},$Z$1:$Z$99,$Y$1:$Y$99),2,False) to lookup Y values to left of Z values.

Forum statistics

Threads
1,216,769
Messages
6,132,603
Members
449,739
Latest member
alexismce

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top