Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do you loop through items in a listbox?

Status
Not open for further replies.

Apollo6

Technical User
Jan 27, 2000
418
US
Here is my issue:

I have built a form that has two listboxes on it. I have a loop that populates Listbox1 with all the sheets in a given workbook. The user clicks on a sheet in Listbox1 and it is added to Listbox2. What I need to be able to do is once the user is finished selecting the sheets they want in Listbox2, print just the sheets listed in Listbox2. I would think it would be some type of loop.

Or if that is not do-able, how could a code it to where the sheets that are in Listbox2 are selected in the activeworkbook? If I could make all the sheets active that are selected, I could bring up xlDialogPrint which would have the print "Selection" option.

Any ideas are appreciated.
 
May I'm thinking too simple, but wouldn't this work?
Code:
For i = 0 To listbox2.ListCount - 1
    sheets(listbox2.list(i)).activate
    (your print instruction here)
Next i
Rob
 
Maybe I'm just not thinking!!! That did the trick! End of the week!!!

Thanks
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top