Hi, Beam_me_up,
a) check any entry into the box to be numeric
Private Sub uniqueref_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger)
Select Case KeyAscii
Case 48 To 57
Case Else
KeyAscii = 0
End Select
End Sub
Please try the following amendment to the code (untested):
Private Sub uniqueref_AfterUpdate()
lastrow = Cells(rows.Count, "A").End(xlUp).Row
If WorksheetFunction.CountIf(Range("A1:A" & lastrow), uniqueref) = 0 Then
MsgBox "number does not exist!", vbInformation, "try again"
With uniqueref
.SetFocus
.SelStart = 0
.SelLength = Len(.Text)
End With
Exit Sub
Else
findrow = Range("A1:A" & lastrow).Find(uniqueref.Value, Cells(1, 1)).Row
For I = 1 To 6
UserForm1.Controls.Item("TextBox" & CStr(I)).Value = Cells(findrow, I).Value
Next I
End If
End Sub
Ciao,
Holger
Bookmarks