I have data on an excel sheet in the following format:
ItemCode DeliveryDate
5456987 01/24/2009
5456988
5456989 12.24.2009
5456990 12/24/2009
I saved DeliveryDate values ββin an array. I need to decide on the basics of the date, and then print the result on a new sheet. So I need to convert the values ββto an array:
Dim current as Date, highest as Date, result() as Date For Each itemDate in DeliveryDateArray current = CDate(itemDate) if current > highest then highest = current end if ' some more operations an put dates into result array Next itemDate 'After activating final sheet... Range("A1").Resize(UBound(result), 1).Value = Application.Transpose(result)
Unfortunately, the CDate () function throws an error:
Runtime Error '13':
Type mismatch
Is there a function in VBA that can:
- parse a string with any date format and return a date object to work with.
- returns an empty date object if the string is empty or incorrect (for comparison in a loop).
Edit:
To reproduce the error, simply run myDate = CDate("24.01.2009")
source share