populate combo with month and year

P

Paulc

Hi,

I'm using XL 2002.

How do I populate ComboBox1 programtically, with a range of month and years
(using the format mmm-yy) starting with the current month of the current
year, incrementing monthly, year on year for 12 months?

So the combo would contain Apr-07 and end with Apr-08

Any ideas appreciated. Thank you.

Paul.
 
G

Greg Maxey

In the userform initialize event use something like:
Private Sub UserForm_Initialize()
Dim i As Long
Me.ComboBox1.AddItem Format(Date, "mmm yy")
For i = 1 To 11
Me.ComboBox1.AddItem Format(DateAdd("m", i, Date), "mmm yy")
Next i
End Sub
 
P

Paulc

XL'nt - thank you.

Greg Maxey said:
In the userform initialize event use something like:
Private Sub UserForm_Initialize()
Dim i As Long
Me.ComboBox1.AddItem Format(Date, "mmm yy")
For i = 1 To 11
Me.ComboBox1.AddItem Format(DateAdd("m", i, Date), "mmm yy")
Next i
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top