I have a snippet of code below that is supposed to compare the date entered in TextBox4 with a reference date in TextBox16. If the two match, then it makes TextBox4 blank (this reduced clutter on a worksheet with mostly the same dates).
My problem is that if "5/15/19" is entered into TextBox4, it doesn't find that equal to "5/15/2019" in TextBox16, yet as soon as the Userform is closed, the value transcribed onto the worksheet by TextBox4 ends up being "5/15/2019". Can anyone help me get any valid date (mm/dd/yy, mm/dd/yyyy, dd-mmm-yy, etc) entered in TextBox4 to be compared in the same format that TextBox16 uses (mm/dd/yyyy)?
My problem is that if "5/15/19" is entered into TextBox4, it doesn't find that equal to "5/15/2019" in TextBox16, yet as soon as the Userform is closed, the value transcribed onto the worksheet by TextBox4 ends up being "5/15/2019". Can anyone help me get any valid date (mm/dd/yy, mm/dd/yyyy, dd-mmm-yy, etc) entered in TextBox4 to be compared in the same format that TextBox16 uses (mm/dd/yyyy)?
Code:
If Me.TextBox4.Value = Me.TextBox16.Value Then
Me.TextBox4.Value = ""
End If
Selection.Offset(0, 2).Value = Me.TextBox4.Value