EnterKey to press button in VBA Userform

后端 未结 6 996
春和景丽
春和景丽 2020-12-31 04:45

I have a userform in Excel that asks for a username and password. Once you enter your password if you press Enter it just \"selects\" the next item which is the <

6条回答
  •  无人及你
    2020-12-31 05:15

    This one worked for me

    Private Sub TextBox1_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer)
            If KeyCode = 13 Then
                 Button1_Click
            End If
    End Sub
    

提交回复
热议问题