ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   combobox increment (https://www.excelbanter.com/excel-programming/375178-combobox-increment.html)

KneeDown2Up

combobox increment
 
Is there a way of using a for/next routine to call a multitude of comboboxes.
i.e, if I have say, 100 comboboxes, something like

combo = combobox & i
for i = 0 to 99
me.cells(rowno,cellno) = combo.value (this being each combo box from
combobox1 onwards)

next i

as opposed to having to type out a routine for each combobox?

Thanks


WhytheQ

combobox increment
 
I think you'll need to use an object variable and then Set this
variable to each Combobox in turn.
So something more like:

Dim Combo as Object
Dim i as Integer

for i = 0 to 99
set Combo = combo & i
cells(rowno,cellno) = combo.value
next i


(not tested so my throw a bug, but I'm sure it is moving in the correct
direction)

Rgds
J


KneeDown2Up wrote:

Is there a way of using a for/next routine to call a multitude of comboboxes.
i.e, if I have say, 100 comboboxes, something like

combo = combo & i
for i = 0 to 99
me.cells(rowno,cellno) = combo.value (this being each combo box from
combobox1 onwards)

next i

as opposed to having to type out a routine for each combobox?

Thanks



KneeDown2Up

combobox increment
 
Ok, thanks for that. It comes back with an error message of Object variable
not set?

I then changed the line ' Set combo = combo & i' to 'Set combo = combobox &
i ' and received a "Object required" error.

"WhytheQ" wrote:

I think you'll need to use an object variable and then Set this
variable to each Combobox in turn.
So something more like:

Dim Combo as Object
Dim i as Integer

for i = 0 to 99
set Combo = combo & i
cells(rowno,cellno) = combo.value
next i


(not tested so my throw a bug, but I'm sure it is moving in the correct
direction)

Rgds
J


KneeDown2Up wrote:

Is there a way of using a for/next routine to call a multitude of comboboxes.
i.e, if I have say, 100 comboboxes, something like

combo = combo & i
for i = 0 to 99
me.cells(rowno,cellno) = combo.value (this being each combo box from
combobox1 onwards)

next i

as opposed to having to type out a routine for each combobox?

Thanks





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

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