Hi Guys, I need your expertise to solve on this issue. From code below, the textBox will stuck after find the duplicate no. Any help will appreciate.
Dim blnRun As Boolean
Private Sub Label29_Click()
Me.Hide
Unload UserForm1
UserForm2.Show
End Sub
Private Sub TextBox2_Change()
Dim rng As Range
Dim lngCtr As Long
If blnRun Then Exit Sub
If Len(TextBox2.Text) = 12 Then
blnRun = True
If WorksheetFunction.CountIf(Sheets("data").Range("A:A"), TextBox2.Text) > 0 Then
MsgBox "This Employee Number already exists"
TextBox2.Text = ""
TextBox2.SetFocus
Exit Sub
Else
With Sheets("data").Range("A" & Rows.Count).End(xlUp).Offset(1, 0)
.Value = TextBox2.Text
.Offset(0, 6).Value = Now
End With
End If
For lngCtr = 2 To 7
Controls("Label" & lngCtr + 3).Caption = Sheet4.Cells(4, lngCtr).Value
Next lngCtr
Set rng = Sheets("Data").Range("A1").CurrentRegion.Find(CStr(TextBox2.Value), , xlFormulas, xlPart)
If Not rng Is Nothing Then
Label3.Caption = rng.Value
Label4.Caption = rng.Offset(, 1).Value
Label28.Caption = rng.Offset(, 5).Value
Application.Wait Now() + TimeValue("00:00:03")
Label3.Caption = ""
Label4.Caption = ""
Label28.Caption = ""
End If
Set rng = Nothing
TextBox2.Text = ""
TextBox2.SetFocus
blnRun = False
End If
Call KeepTime
End Sub
Thank you
Dean
Bookmarks