hi
my code works well except for one, it doesn't display the message that file doesnt exists when performing search using .find in excel...please correct my coding below. im sorry if i could not attached a sample workbook for this inquiry.
Private Sub searchupdate()
Dim MatchCell As Range
Dim strFind, FirstAddress As String 'what to find
Dim rSearch As Range 'range to search
'Dim f As Integer
'Search Range is the ID numbers column
Set rSearch = ActiveSheet.Range("C10", Cells(Rows.Count, "C").End(xlUp))
'ID number to find
strFind = TextBox1.Value
'Allways set All the Named Argumnets for the First Search.
'The system "Find" function uses these settings also.
With rSearch
Set MatchCell = .Find(What:=strFind, _
LookIn:=xlValues, _
LookAt:=xlWhole, _
SearchOrder:=xlRows, _
SearchDirection:=xlNext, _
MatchCase:=False)
If Not MatchCell Is Nothing Then 'found it
'load entry to form
lblemployee.Caption = MatchCell.Offset(0, 1).Value 'Employee name
lblshift.Caption = MatchCell.Offset(0, -1).Value 'shift
lblcoach.Caption = MatchCell.Offset(0, -2).Value 'coach
ListBox1.RowSource = MatchCell.Offset(0, 2).Resize(1, 10).Address
'ListBox1.ListIndex = 0
FirstAddress = MatchCell.Address
CurRow = MatchCell.Row
TextBox2.SetFocus
Do
Set MatchCell = .FindNext(rSearch)
Loop While Not rSearch Is Nothing And MatchCell.Address <> FirstAddress
If TextBox1.Value = "" And TextBox2.Value = "" Then
MsgBox "Please enter Employee ID", vbExclamation + vbOKOnly, "Invalid Input"
TextBox1.SetFocus
End If
End If
End With
Set MatchCell = Nothing
End Sub
regards,
stoey
Bookmarks