ipbr21054
Well-known Member
- Joined
- Nov 16, 2010
- Messages
- 5,226
- Office Version
- 2007
- Platform
- Windows
Morning,
I have a userform where i type in txtInput field a value then pressing the btkOK button runs the code.
I just dont see what triggers the code to close the userform & advise me the answer as the code for the btnOK button is just Hide ??
Basically im trying to just run the code with pressing Enter on the keyboard
I have a userform where i type in txtInput field a value then pressing the btkOK button runs the code.
I just dont see what triggers the code to close the userform & advise me the answer as the code for the btnOK button is just Hide ??
Basically im trying to just run the code with pressing Enter on the keyboard
Rich (BB code):
Private Sub CommandButton1_Click()
Dim ans As String
Dim Fnd As Range
Dim varNRows As Long
Dim varFndRow As Long
varNRows = Cells(Rows.Count, "A").End(xlUp).Row
Range("A4:" & "A" & varNRows).Interior.Color = vbGreen
HondaListVinForm.Show
ans = HondaListVinForm.txtInput.Text
HondaListVinForm.txtInput.Text = ""
HondaListVinForm.txtInput.SetFocus
If ans = "" Then Exit Sub
EX:
Set Fnd = Range("A4:A" & varNRows).Find _
(ans, Range("A" & varNRows), , xlPart, , , False, , False)
If Not Fnd Is Nothing Then
varFndRow = Fnd.Row
Cells(varFndRow, "A").Interior.Color = RGB(51, 255, 255)
MsgBox "THE NEAREST MATCH IS AT ROW " & varFndRow, vbInformation
Cells(varFndRow, "A").Select
Else
ans = Left(ans, Len(ans) - 1)
GoTo EX
End If
End Sub