rhino4eva
Active Member
- Joined
- Apr 1, 2009
- Messages
- 262
- Office Version
- 2010
- Platform
- Windows
VBA Code:
Private Sub CommandButton1_Click()
Dim txtLabNo As Variant, m As Variant
Dim i As Long
Dim wsMaster As Worksheet
'lab number
txtLabNo = Left(Me[COLOR=rgb(209, 72, 65)].[/COLOR][COLOR=rgb(65, 168, 95)]LabNumBOX[/COLOR], 7)
If Not IsNumeric(txtLabNo) Then Exit Sub Else txtLabNo = Val(txtLabNo)
'change master sheet name as required
Set wsMaster = ThisWorkbook.Worksheets("DATA")
'search column A
m = Application.Match(txtLabNo, wsMaster.Columns(2), 0
If Not IsError(m) Then
'post to master sheet
wsMaster.Cells(CLng(m), 4).Value = "x"
Me.LabNumBOX = ""
LabNumBOX.SetFocus
Else
'inform user
MsgBox txtLabNo & Chr(10) & "Record Not Found", 48, "Not Found"
End If
End Sub
So i have a userform that searches for a a Lab number in a Column A given the text in a Userform text box(LabNumBOX)
This lab number is from a bar code reader that has a carriage return as a default. The code above actioned by pressing a button.
How can i get the textbox to run automatically without having to press the button