I have a userform where I have a textbox. Everytime the user types in a pallet number then hits the 'enter' key, I want it to save the value to a cell defined as the last row and column. Then I want the textbox to clear and the focus to stay in the text box when the user presses enter so that they can enter in another value and so on. But the problem is when the user hits enter it will enter in the data into the correct cell, but the userform will lose focus and it will just tab over to the next item in the tabindex.
Maybe I'm going about this the wrong way, but I can't seem to figure out this issue.
Maybe I'm going about this the wrong way, but I can't seem to figure out this issue.
Code:
Private Sub TextBoxIndividualPallet_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer)
If KeyCode = vbKeyReturn Then
LastHold = Sheets("Holds").Range("A" & Rows.Count).End(xlUp).Row
With Sheets("Holds")
LastCol = .Cells(LastHold, .Columns.Count).End(xlToLeft).Column
End With
Cells(LastHold, LastCol + 1) = "U" & TextBoxIndividualPallet.Value
TextBoxIndividualPallet.Value = ""
TextBoxIndividualPallet.SetFocus
End If
End Sub