+ Reply to Thread
Results 1 to 3 of 3

Populating Two Listboxes with Sheets Based on Cell Value & Printing Their Selection

  1. #1
    Registered User
    Join Date
    07-14-2009
    Location
    Brighton, England
    MS-Off Ver
    Excel 97
    Posts
    49

    Populating Two Listboxes with Sheets Based on Cell Value & Printing Their Selection

    Hello, once again I have hit a brick wall (I seem to do it a lot).

    What I would like to do is have 2 listboxes. In the first listbox I would like the name of all the worksheets which contain the words "elective class: " in cell C7.

    In the second listbox I would like the name of all the worksheets which do not contain the words "elective class: " in C7. I need this only to source from worksheet 7 onwards however.

    The listboxes are called ListBox1 and ListBox2 respectively.

    Also I am using this to print and I have a button which currently selects all the data in the first listbox and another button which prints all the selected data. The code being used for this is:

    Please Login or Register  to view this content.
    What would I need to change this to to print anything selected in either listbox?

    Finally out of interest since I am doing all of this to learn more than anything, is there a way to define which printer to print to so that even if the default printer is for example a non-colour one. Pressing a button saying perhaps "print colour" would always print to the colour printer?

    Thanks always,

    Tom
    Last edited by TBrooker; 08-14-2009 at 03:48 AM.

  2. #2
    Registered User
    Join Date
    07-14-2009
    Location
    Brighton, England
    MS-Off Ver
    Excel 97
    Posts
    49

    Re: Populating Two Listboxes with Worksheets Based on Cell Value

    A few codes I have tried so far but have not worked are:

    Please Login or Register  to view this content.
    Please Login or Register  to view this content.
    Also have done a couple variations of the second of the two codes including counters and an index to start the population from the seventh worksheets along but I had no luck.

    I am guessing I have made a basic error or if there is a completely different formula which would work better, then I am more than happy with that also. I'll probably turn screen updating off for both of these too.

    For the printing which I haven't had a chance to test yet as I haven't populated both listboxes this is the code I have put in:

    Please Login or Register  to view this content.
    I'm pretty sure its wrong...

    Many thanks,

    Tom

  3. #3
    Registered User
    Join Date
    07-14-2009
    Location
    Brighton, England
    MS-Off Ver
    Excel 97
    Posts
    49

    Re: Populating Two Listboxes with Worksheets Based on Cell Value

    In case anybody wanted to do similar I have now worked out how to do what I wanted, the code used is as follows:

    Populating the Listboxes

    Please Login or Register  to view this content.
    Quite an easy code to modify if need be.

    To add a second condition instead of just adding any worksheets without a value in cell C7 you can change the Else line to
    Please Login or Register  to view this content.
    The line ListBox1.Clear caused the problem if you were using it in the initialization however if you wanted a refresh button this and ListBox2.Clear are the lines you can add to code for one.

    Printing

    For printing from both listboxes the code used is:

    Please Login or Register  to view this content.
    Tom
    Last edited by TBrooker; 08-14-2009 at 03:55 AM.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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