PDA

View Full Version : Array for months of the calendar



buddy2000
03-05-2011, 01:00 PM
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.

Bob Phillips
03-05-2011, 02:07 PM
Redim VecDates(1 To 12)
For i = 1 To 12

vecDates(i) = DateSerial(Year(Date),i, 1)
Next i

Tinbendr
03-06-2011, 08:00 AM
To expand on Bob's answer, to get the months proper name:
vecDates(i) = Format(DateSerial(Year(Date), i, 1), "MMMM")

Zack Barresse
03-06-2011, 10:25 AM
To expand on Bob's answer, to get the months proper name:
vecDates(i) = Format(DateSerial(Year(Date), i, 1), "MMMM")
Actually it's easier than that, no need for calling two functions...
vecDates(i) = MonthName(i, False)