Populate Form's Drop Box with Array from VBA?

Bilbo_Baggins_Esq

Registered User.
Local time
Yesterday, 19:16
Joined
Jul 5, 2007
Messages
586
I have a Form in Excel with a ComboBox.

I need to populate it with year values.

for example:
2010
2011
2013
2014
2015

Except really there needs to be 100 years to either side of the current year.
Or, it could be between a range of years, say 1800 to 2100.
The point here is, it is a crap load of values to get into a RowSource for a Excel Form ComboBox.

So, obviously I can simply put some values in some cells of a worksheet and refer to them in the RowSource property of the ComboBox
However, that makes my code dependent on the worksheet.

I’d rather find a way to do it within VBA.

I’m thinking perhaps an array? Something else maybe?

Anybody have any creative ideas?

Thanks in Advance!
 
What about the .AddItem method ?
Code:
For i = 1900 - 100 to 1900 + 100
  cmbComboName.AddItem i
Next i
 
Thanks for the suggestion and it worked great.

Don’t know why that method didn’t occur to me, but thanks for being there!
 

Users who are viewing this thread

Back
Top Bottom