ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Combo Box (https://www.excelbanter.com/excel-programming/304170-combo-box.html)

No Name

Combo Box
 
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

Bryan[_10_]

Combo Box
 
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

wrote in message
...
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




No Name

Combo Box
 
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

wrote in message
...
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



.



All times are GMT +1. The time now is 02:14 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com