Hi all, I'm trying to get the often asked question how to clear the immed wind programatically. this almost works but it not only clears it when the sub is called but also reclears it even after other code is run it's like it's on some kind of automatic loop or something Sub ClearImmediateWindow() Application.VBE.Windows.Item("Immediate").SetFocus SendKeys "^a" SendKeys "{del}" 'here there must be required something to close this operation but I don't know what it might be End Sub Sub test() Dim i As Integer While i < 10 Debug.Print i i = i + 1 Wend ClearImmediateWindow While i < 20 Debug.Print i i = i + 1 Wend End Sub that test sub should leave 11 - 20 showing in immediate window but it acts like it's recalling the clearImmediateWindow sub a second time after the second while loop any thoughts? Thanks Mark