I think this is the problem:
Private Sub cmbFind_Click()
Dim lastrow
Dim myContractNumber As String
lastrow = Sheets("Sheet1").Range("A" & Rows.Count).End(xlUp).Row
myContractNumber = txtContractNumber.Text
For currentrow = 2 To lastrow
If Cells(currentrow, 1).Text = myContractNumber Then
txtContractNumber.Text = Cells(currentrow, 1).Text
txtClient.Text = Cells(currentrow, 4).Text
End If
Next currentrow
txtContractNumber.SetFocus
End Sub
You loop through looking for a match with the contract number and, when you get one, you update the client name. However, you then continue to loop through the data to the lastrow ... hence the currentrow will always equal the lastrow. I think you just need to add an Exit Sub when you find the client you are looking for.
Private Sub cmbFind_Click()
Dim lastrow
Dim myContractNumber As String
lastrow = Sheets("Sheet1").Range("A" & Rows.Count).End(xlUp).Row
myContractNumber = txtContractNumber.Text
For currentrow = 2 To lastrow
If Cells(currentrow, 1).Text = myContractNumber Then
txtContractNumber.Text = Cells(currentrow, 1).Text
txtClient.Text = Cells(currentrow, 4).Text
Exit Sub
End If
Next currentrow
txtContractNumber.SetFocus
End Sub
Regards, TMS
Bookmarks