I am trying to convert a date from text format to date format. The code I have provided below works great for all dates that have as dd a number bigger than 12 .So for dd=13 to dd=31 it works fine. When I have a date with dd<13 then it just not work. the date I am providing below is an example of a date that the code wont work. It leaves the cell B1 empty. Also, my system settings are set for dd/mm/yyyy so its ok with the system. anyone knows why it does not work?
Sheets("1").Select
Dim myValue As Variant
myValue = InputBox("Simi, type the date of the shipments that you want to create the report for", "Date", 1)
Sheets("1").Range("B1").Value = myValue
With Sheets("1").Range("B1")
Dim t() As String
t = Split(myValue, "/") ' Split into pieces
If UBound(t) = 2 Then ' If 3 elements found:
myValue = DateSerial(t(2), t(1), t(0)) ' Convert to Date
End If
End With
Withcommand does. you are using it in an absolutely incorrect way, and it will get you into trouble in the future.