I am very new to Vba. I am sure this is simple but can some please show me how to create an Array for the months of the year. It must be in a loop and populate the array with the months. I have tryed but what I am trying is not even close.
I am very new to Vba. I am sure this is simple but can some please show me how to create an Array for the months of the year. It must be in a loop and populate the array with the months. I have tryed but what I am trying is not even close.
[vba]
Redim VecDates(1 To 12)
For i = 1 To 12
vecDates(i) = DateSerial(Year(Date),i, 1)
Next i
[/vba]
____________________________________________
Nihil simul inventum est et perfectum
Abusus non tollit usum
Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
James Thurber
To expand on Bob's answer, to get the months proper name:
[VBA]vecDates(i) = Format(DateSerial(Year(Date), i, 1), "MMMM")[/VBA]
David
Actually it's easier than that, no need for calling two functions...Originally Posted by Tinbendr
[vba]vecDates(i) = MonthName(i, False)[/vba]
Regards, Zack Barresse
Check out the KB! :|: BOARD TAGS: WHAT ARE THEY AND HOW DO I USE THEM
What is a Microsoft MVP? | Free Microsoft Courses | My Book on Excel Tables