+ Reply to Thread
Results 1 to 8 of 8

loop through selection in list box

  1. #1
    Forum Contributor
    Join Date
    07-16-2009
    Location
    Montreal, Canada
    MS-Off Ver
    Excel 2013
    Posts
    114

    loop through selection in list box

    I have a multi select list box that lists the cell contents of row 1 from a range of CB1 to the end of the sheet. and puts them into a single column list. what i'm trying to do is take the items that are selected and produce 6 pdfs of each selection (1 for each price level) I know how to produce the pdfs and format the data. I was thinking of using a template worksheet and copy the columns over and do 1 sheet at a time. but i'm unsure if this is the most efficient method because it could be up to 150 pdf's. also I don't know how to take the items selected in the list box and transfer it to the macro. any advice would be great.

    here is the code for the listbox

    Please Login or Register  to view this content.
    Thanks,

    Chris
    Last edited by Code Flunkie; 09-03-2014 at 02:20 PM.

  2. #2
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: loop through selection in list box

    Chris

    Do you just want to loop through the listbox?
    Please Login or Register  to view this content.
    If posting code please use code tags, see here.

  3. #3
    Forum Expert Tinbendr's Avatar
    Join Date
    06-26-2012
    Location
    USA
    MS-Off Ver
    Office 2010
    Posts
    2,125

    Re: loop through selection in list box

    Please Login or Register  to view this content.
    David
    (*) Reputation points appreciated.

  4. #4
    Forum Contributor
    Join Date
    07-16-2009
    Location
    Montreal, Canada
    MS-Off Ver
    Excel 2013
    Posts
    114

    Re: loop through selection in list box

    No, I want to loop through the columns they refer to and for each column selected do something

  5. #5
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: loop through selection in list box

    If you mean you want to loop through the selected items in the listbox see Tinbendr's code.

  6. #6
    Forum Contributor
    Join Date
    07-16-2009
    Location
    Montreal, Canada
    MS-Off Ver
    Excel 2013
    Posts
    114

    Re: loop through selection in list box

    I don't think I was very clear, the listbox is composed of the values of the first row of a range of columns ie

    "cb1" value
    "cc1" value
    "cd1" value
    etc...

    what i want to do is if say cb1 and cd1 is selected I want to take those full columns and loop through for example

    do stuff with cb1
    then do stuff with cd1
    etc...

    hopefully that clears it up.

  7. #7
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: loop through selection in list box

    The thing is, we don't know what 'stuff' it is you want to do so can only really suggest the basic code for the loop.

    Below I've added to Tinbendr's code to set a range, rngCol, for the selected column(s) as you loop.

    Please Login or Register  to view this content.

  8. #8
    Forum Contributor
    Join Date
    07-16-2009
    Location
    Montreal, Canada
    MS-Off Ver
    Excel 2013
    Posts
    114

    Re: loop through selection in list box

    I know how to do the other stuff, it was just going from the selection to the actual columns I was unclear of. I think this should work.

    thanks for all the help.

    Chris

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] Macro that will loop through a filtered list and print each selection
    By bobbysue25 in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 04-28-2017, 08:07 AM
  2. Autolock Cells from a Drop Down List Selection and a Calendar Selection
    By John Anderson in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 02-04-2013, 10:54 AM
  3. List Box Selection / Highligh Selection Code
    By Dr.SUN in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 09-28-2010, 11:48 PM
  4. List Box selection based on combo box selection
    By MFA in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 07-09-2008, 10:19 AM
  5. [SOLVED] Using loop for selection macro
    By akoobra in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 01-28-2005, 02:06 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1