Here you go...just modified your cboLot event handler:
Private Sub cboLot_Change()
Dim rng As Range
Dim cell As Range
Set sh = ThisWorkbook.Sheets("Expiry")
Set rng = sh.Range("A2", sh.Cells(sh.Rows.Count, "A").End(xlUp))
On Error Resume Next
For Each cell In rng.Cells
If cell.Value = Me.cboReagent.List(Me.cboReagent.ListIndex) Then
If CStr(cell(1, 2).Value) = Me.cboLot.List(Me.cboLot.ListIndex) Then
TextBox3.Value = cell(1, 3).Text
g_Date_Expiry = cell(1, 3).Value
If cell(1, 3).Value <= Date Then
MsgBox ("This lot expired. Please select different lot.")
Unload UserForm1
UserForm1.Show
End If
Exit Sub
End If
End If
Next cell
End Sub
Bookmarks