[RESOLVED] Making code run when the user hits 'Enter' in a text box
Good Morning,
I want to make some code run when the user hits enter in a text box on my userform.
I cant use the run on text change thingy because that will make it run every time the form is loaded, and we dont want that.
So any idea's how, or what the prefix is, to make code run when the user hits the enter key in a certain text box?
Thankyou for all your help!
Re: Making code run when the user hits 'Enter' in a text box
Code:
Private Sub Textbox1_KeyPress(KeyAscii As Integer)
Select Case KeyAscii
Case 13
' do your thing
Case Else
'do other thing
End Select
End Sub
Re: Making code run when the user hits 'Enter' in a text box
Thanks very much, i worked it out just before you posed that reply!!
vb Code:
Private Sub txtPA_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer)
Dim NewPA As String
If KeyCode = vbKeyReturn Then
Call Module2.Update