Dear All,
I need your help on this. Let say once Text box1 activated after accept only 12 digit, then will transfer the data to cell A1 with data into text box 2 message "welcome 12345678". Then if have any duplicate, it will promt the message into Text Box 2. The code below I get from this forum.
Private Sub Data_Change()
Dim RowCount As Long
Dim xlRng As Range
If Trim(Me.TextBox1.Value) = vbNullString Then
MsgBox "Please Swipe Your Card!", vbOKOnly + vbInformation, "Message"
Text Box1.Text = ""
Me.Data.SetFocus
Exit Sub
End If
Set xlRng = Worksheets("Sheet1").Columns(1).Find(What:=Me.TextBox1.Value, LookIn:=xlValues, lookat:=xlWhole)
If Not xlRng Is Nothing Then
MsgBox "You already have swiped!", vbOKOnly + vbInformation, "Message"
TextBox2.Text = ""
Me.TextBox1.SetFocus
Me.TextBox1.SelStart = 0
Me.TextBox1.SelLength = Len(Me.TextBox1.Value)
Exit Sub
End If
RowCount = Worksheets("Sheet1").Range("A1").CurrentRegion.Rows.Count
With Worksheets("Sheet1").Range("A1")
.Offset(RowCount, 0).Value = Me.TextBox1.Value
End With
RefreshUserForm1
End Sub
Thank you all.
Bookmarks