Assign variable ListBox names

  • Thread starter Thread starter chris
  • Start date Start date
C

chris

I have a user form with three list boxes. Is there a "For" statement
(similar to below) that will loop through each of the three list boxes
and execute a "with" command?

For x = 1 to 3
With UserForm1.ListBox(x)
.additem = A
.additem = B
End With
next x

Any help is greatly appreciated, thank you!
 
For x = 1 to 3
With UserForm1.Controls("ListBox" & i)
.additem = A
.additem = B
End With
next x
 
Is it safe to assume that the "i" should be an "x"? I am also
receiving a Run-time error '438'. Any ideas for a solution?

Thanks!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top