PDA

View Full Version : Solved: A Simple(?) ComboBox Query



mpewsey
07-12-2007, 06:40 AM
I've been pulling my hair out since lunch with what I'm sure is a simple problem.

I've got a ComboBox on a user form. When the form initialises I want it to be populated with the current date in the format "Mon-YY" along with the following 11 months (ie: 12 months in total).

I'm sure I've done this before but can't for the life of me remember how I did.

Can one of you save my sanity?

Martin

mvidas
07-12-2007, 06:43 AM
Hi Martin,

Sure, but who needs sanity? :)Private Sub UserForm_Initialize()
Dim i As Long
For i = 0 To 11
ComboBox1.AddItem Format(DateSerial(Year(Date), Month(Date) + i, 1), "mmm-yy")
Next
End Sub

mpewsey
07-12-2007, 06:48 AM
Matt

Many thanks - that's a drink I owe you.

What little sanity I have left is preserved - and the girls in the office don't have to watch a grown man crying any more!!

Martin