ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Looping through multiple controls (https://www.excelbanter.com/excel-programming/293472-looping-through-multiple-controls.html)

rci

Looping through multiple controls
 
Hi all...

I have a multipage object, with a list box on each page.

I would like to loop through all of the listbox objects in a for next
loop... checking/setting properties.

How can I do this? They don't have an index property... but I have named
them LB1, LB2, LB3...

Ideas?

Thanks,

Mike

Tom Ogilvy

Looping through multiple controls
 
Even though they are on pages of a multipage, I believe you can reference
them directly from the userform

Dim lbox as MSForms.Listbox
for i = 1 to 4
set lbox = Userform1.Controls("LB" & i)
lbox.listindex = -1
Next

--
Regards,
Tom Ogilvy

"rci" wrote in message
...
Hi all...

I have a multipage object, with a list box on each page.

I would like to loop through all of the listbox objects in a for next
loop... checking/setting properties.

How can I do this? They don't have an index property... but I have named
them LB1, LB2, LB3...

Ideas?

Thanks,

Mike




pikus

Looping through multiple controls
 
For x = 1 To Worksheets.Count
Worksheets(x).ListBox(1)
Next x

- Piku

--
Message posted from http://www.ExcelForum.com



All times are GMT +1. The time now is 05:32 AM.

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