Im having trouble with some error trapping code ive written for a range date Sub.
Ive tagged the code in below. Basically Ive copied this piece of code from a previous Macro which uses the dd-mm-yy date format, but useing this same format within the new macro for me is is returning my "Invalid date format" error.
Is there somthing I need to do within the VBA options to define the date formats accepted?
Thanks in advance for your help!
Sub RangeDate()
If TextBox2.Value = "" Then
MsgBox ("Enter start of Drawdown week")
NoDate = True
Exit Sub
Else
NoDate = False
ThisWeekDate = TextBox1.Value
End If
If TextBox3.Value = "" Then
MsgBox ("Enter end of Drawdown Week")
NoDate = True
Exit Sub
Else
NoDate = False
ThisWeekDate = TextBox1.Value
End If
If Not (IsDate(TextBox1.Value) And IsDate(TextBox2.Value)) Then
MsgBox "Invalid date format"
NoDate = True
Exit Sub
ElseIf CDate(TextBox2.Value) <= CDate(TextBox1.Value) Then
MsgBox ("Dates entered incorrectly")
NoDate = True
Exit Sub
Else
ThisWeekDate = TextBox2.Value
End If
End Sub
Bookmarks