My code is reporting:
Run Time Error 13:
Type mismatch.
How can that be if I use an iferror
function?
Please note, the value in payroll_Start
or payroll_Last
should be a date but it could be blank or some idiot user could input a string. Thus, I need to do a check with iferror
. However, the check produces the above error. What does this mean? Thank you in advance.
Private Sub CheckStartLast()
'''''<<<<< Check for error: Employee's last day cannot be before start day.
payroll_Start = UserForm9.ComboBox21.Value
payroll_Last = UserForm9.ComboBox22.Value
payroll_Diff = WorksheetFunction.IfError(payroll_Last - payroll_Start, "-Check-")
Select Case payroll_Diff
Case Is = "-Check-"
Exit Sub
Case Is >= 0
Exit Sub
Case Is < 0
MsgBox "Employee's start date cannot be after their last day. Doesn't make sense. Does it to you?"
Case Else
Exit Sub
End Select
End Sub