Glory
Well-known Member
- Joined
- Mar 16, 2011
- Messages
- 640
eg So that if the date is entered as "4-3", the date becomes "04/03/2011"
Code:
On Error GoTo YearAdder
DateTxt1 = Replace(DateTxt1, "-", "/")
fourtharray = Split(DateTxt1, "/")
If fourtharray(0) < 10 And _
Len(fourtharray(0)) < 2 Then: fourtharray(0) = "0" & fourtharray(0)
If fourtharray(1) < 10 And _
Len(fourtharray(1)) < 2 Then: fourtharray(1) = "0" & fourtharray(1)
On Err.Number = 9 GoTo YearAdder
If Len(fourtharray(2)) = 2 Then: fourtharray(2) = "20" & fourtharray(2)
If IsEmpty(newdate) Then: newdate = Join(fourtharray, "/")
DateTxt1 = newdate
YearAdder:
If Err.Number = 9 Then: newdate = Join(fourtharray, "/") & "/" & Year(Date)
Resume Next