I am very, very new to programming in VBA. I have come up with the following code for VBA. But, it doesn't work. I can still enter a duplicate. Can someone please share with me what I'm doing wrong?
If Trim(Me.txtheatcode.Value) = "" Then
MsgBox "Please enter a Heat Code"
If Trim(Me.txtheatcode.Value) = (Sheets("PartsData").Range("D2:D999")) = 0 Then
MsgBox "Duplicate Heat Code Found"
Me.txtheatcode.SetFocus
End If
Thank you for your time.
If Trim(Me.txtheatcode.Value) = "" Then
MsgBox "Please enter a Heat Code"
If Trim(Me.txtheatcode.Value) = (Sheets("PartsData").Range("D2:D999")) = 0 Then
MsgBox "Duplicate Heat Code Found"
Me.txtheatcode.SetFocus
End If
Thank you for your time.