How can I modify this code so that a message box pops up when the criteria is not found and avoid getting the error "no cells were found"?
Thanks,
CEG
Code:
Private Sub tbJobNo_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer)
If KeyCode = 13 Then
Dim xVal As Variant
Worksheets("part number").AutoFilterMode = False
With Worksheets("part number").Range("Job_No")
.AutoFilter Field:=1, Criteria1:=frmDQT.tbJobNo.Value
If .Range("Job_No") Is Nothing Then
Exit Sub
frmDQT.cboPN.Clear
For Each xVal In .Columns(2).SpecialCells(xlCellTypeVisible)
frmDQT.cboPN.AddItem xVal.Value
Next xVal
.AutoFilter
End With
End If
ActiveSheet.Rows("3:3").Hidden = True
tbPartNo = ""
End Sub
CEG