Answers for "excel vba close form escape key"

VBA
1

excel vba close form escape key

' In the userform code (must also be command controls if any, 
' for example buttons, for Keypress event)
Private Sub UserForm_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger)
    If KeyAscii = 27 Then Unload Me
End Sub
' Or on at least one / all buttons:
button.Cancel = True
' Or if none add a button to the userform with:
With button
    .Height = 0
    .Width = 0
    .Cancel = True
End Width
Posted by: Guest on February-07-2021

Code answers related to "VBA"

Browse Popular Code Answers by Language