I'm new in VBA, first I have a userform, textbox1 and a commandbutton1. I have problem when I enter or press Tab in textbox1 , I want textbox1 still in setfocus but it clicked commandbutton1.
I have code below:
Private Sub TextBox1_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, _
ByVal Shift As Integer)
If KeyCode = 13 Then
TextBox1.SetFocus
End If
End Sub
and what's VBA code to close userform1 when I press "F4" on keyboard? thank you...
Change you code from
to
See THIS. This thread is for Esc key. Change it for F4
LOL. It is one of your threads.