ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Array question (https://www.excelbanter.com/excel-programming/285171-array-question.html)

Lee

Array question
 
In VB, when you copy a control or give two controls the
same name, VB asks if you want to create an array, and
creates the name with a subscript, such as Textbox(1),
Textbox(2), etc. It appears that VBA does not do this.
I'm not sure how to declare an array here.

I have five dropdown combo boxes that I want to each fill
with the same five values, and it seemed most efficient to
do this with an array.

Tom Ogilvy

Array question
 
VBA doesn't support control arrays.

for i = 1 to 5
userform1.Controls("Combobox" & i).List = Array(1,2,3,4,5)
Next

--
Regards,
Tom Ogilvy

"Lee" wrote in message
...
In VB, when you copy a control or give two controls the
same name, VB asks if you want to create an array, and
creates the name with a subscript, such as Textbox(1),
Textbox(2), etc. It appears that VBA does not do this.
I'm not sure how to declare an array here.

I have five dropdown combo boxes that I want to each fill
with the same five values, and it seemed most efficient to
do this with an array.





All times are GMT +1. The time now is 10:06 AM.

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