View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
RyanH RyanH is offline
external usenet poster
 
Posts: 586
Default Close UserForm by pressing Esc key

I think the Userform will close with the Esc Key pressed by default. It does
for me in Excel 2007.

If not, I'd use,

Private Sub UserForm_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal
Shift As Integer)

If KeyCode = 27 Then
Unload Me
End If

End Sub

"Shazi" wrote:

Hi,

I made a userform and I want to close this without pressing the Cancel
button or Close Button. is it possible to close it by pressing Esc
key.

Pls advise me.

Regards.

Shahzad