Hi, I have the following code (see below) which is supposed to select a record in a table when the user enters a customer ID in the textbox of a userform, and then clicks OK, for some reason however, it is not working, when I enter a customer ID in the textbox, and then when I click on OK, all that pop ups is the error message stating that the customer ID could not be found, even when the ID is in actual fact located in the table.
My table starts in cell 7, (cell 6 if including headings) and there are 5099 records and there are 23 fields, so the table ends in column V.
Could someone please help me
Private Sub CommandButton2_Click()
Dim i As Long, lrow As Long, rcount As Long
With Worksheets("Sheet1")
lrow = .Range("B" & .Rows.Count).End(xlUp).Row
For i = 4 To lrow
If .Range("B" & i).Value = TextBox1.Value Then
.Rows(i).Select
rcount = rcount + 1
End If
Next i
If rcount = 0 Then MsgBox "ID not found"
End With
End Sub
Bookmarks