PDA

View Full Version : Cleaner VBA? - Building Array of Months (Fiscal Year)



yogi_bear_79
10-08-2007, 05:41 PM
I successfully use the global variables below to populate arrays, and a combo box throughout my project. I've been looking for a cleaner alternative, I would think that since these are essentially dates, that I could use a built in function? Any tips on cleaner code would be appreciated!

Public Const g_arrShortMonths As String = "Oct 2007,Nov 2007,Dec 2007,Jan 2008,Feb 2008,Mar 2008,Apr 2008,May 2008,Jun 2008,Jul 2008,Aug 2008,Sep 2008"

Public Const g_arrMonths As String = "October,November,December,January,February,March,April,May,June,July,August ,September"

Example of use:
arrShortMonths = Split(g_arrShortMonths, ",")
arrLongMonths = Split(g_arrMonths, ",")

For i = LBound(arrShortMonths) To UBound(arrShortMonths)
If arrShortMonths(i) = strMonth Then


Populating a combo box
cmbMonth.List = Split(g_arrShortMonths, ",")

malik641
10-08-2007, 07:40 PM
Just curious, do you want the months to start on the current month and end on the last month of a year's cycle?

EDIT: Nevermind. Sorry, but didn't notice the "Fiscal Year" in your thread title :)