Reputation: 3
I'm new to Excel VBA and am having trouble initialising an array of dates on a single line using brackets.
I know how to do this with Variant data types:
arrayVariant = Array("hello", "world")
and with string data types:
arrayString = Split("hello,world",",")
and can initialise an array of dates by initialising each item individually:
arrayDates(0) = #01/01/1900#
etc
but I can't find any way to initalise a date array on a single line. Is it possible in VBA?
Upvotes: 0
Views: 1537
Reputation: 41
You can use the same approach for the String type, but converting each value to Date type, using the CDate():
arrayDates = Array(CDate("1/1/2000"), CDate("2/2/2000"), CDate("2/3/2004"))
By using this approach you manage to fill the array in one line.
Upvotes: 1