Combo Box

G

Guest

Hello,

I use a combo box to give a list of dates. I use the code
below to set up the years. Is it possible to make this
list go for the next hundred years or maybe even further,
and additionally to update each year (removing the prior
year) - so that only the current year and out are
displayed. I would also like to do this in a simpler
manner - without having to type each year.

Is this possible??

Thank You,

Private Sub UserForm_Initialize()
yr.AddItem "2004"
yr.AddItem "2005"
yr.AddItem "2006"
yr.AddItem "2007"
yr.AddItem "2008"
yr.AddItem "2009"
yr.AddItem "2010"
yr.AddItem "2011"
yr.AddItem "2012"
yr.AddItem "2013"
yr.AddItem "2014"
yr.AddItem "2015"
End Sub
 
B

Bryan

I haven't tested this code, but something like this should work:

private sub UserForm_Initialize()

dim iYear as integer
dim i as integer 'counter

yr.Clear
for i = year(now) to year(now) + 99
yr.AddItem cstr(i)
next i

end sub
 
G

Guest

Thank You

-----Original Message-----
I haven't tested this code, but something like this should work:

private sub UserForm_Initialize()

dim iYear as integer
dim i as integer 'counter

yr.Clear
for i = year(now) to year(now) + 99
yr.AddItem cstr(i)
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