+ Reply to Thread
Results 1 to 5 of 5

Trying to Print User-Selected Sheets from a button on one sheet.

  1. #1
    Registered User
    Join Date
    10-30-2011
    Location
    Havelock, NC
    MS-Off Ver
    Excel 2007
    Posts
    2

    Trying to Print User-Selected Sheets from a button on one sheet.

    Hello, everyone.

    I am new to this forum and vaguely familiar with VB (had an intro to it a while back), and I simply need to figure out why something isn't working like it should.

    I have an Excel Workbook (2007) with approximately 20 sheets. I set it up so that it is navigable using buttons with macros behind them, and so that only one sheet is visible at a time -to move from one sheet to a different one, the user needs to go back to a main selection sheet (a "switchboard form", if you like). Each sheet has a button to print that sheet, and all of that works perfectly.

    What I am trying to add is a button on the "MASTER" sheet that allows the user to select which sheet he/she wants to print without going to the sheet, and also allows them to print more than one sheet with a single action.

    The best code I have found for this thus far was a piece that I am posting here. It purports to do exactly what I want, but hangs up just before the print. It is meant to create a dialog box on the fly with checkboxes representing the sheets in the workbook. The user selects one or more checkbox(es), then clicks "OK", which is supposed to print the selected sheets.

    The error comes after the sheet(s) are selected, and "OK" is pressed.

    Microsoft KB had a solution to this, but none of the workarounds (they list 4) seem to apply to what I am doing.

    Unfortunately, I cannot see replies to this thread until I get home in the evenings (my network policy at work has blocked this site), and I will not be able to post the workbook because it contains Personally Identifiable Information (PII) on a number of people.

    I can post the code that is giving me trouble, as it is already in the public domain and I will bold and CAP the line that is highlighted when I go into the debugger.

    Any help on this is greatly appreciated.

    The code follows:

    Please Login or Register  to view this content.
    ---End of Code---

    Thank you again for any help you can provide.
    Last edited by rattler418; 10-30-2011 at 08:12 PM. Reason: Title Edit

  2. #2
    Forum Expert
    Join Date
    12-23-2006
    Location
    germany
    MS-Off Ver
    XL2003 / 2007 / 2010
    Posts
    6,326

    Re: Need some help with a bit of VBA code.

    Also please read our rules concerning code tags. I will add them for you this time.

  3. #3
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Need some help with a bit of VBA code.

    Hello rattler418,

    Welcome to the Forum!

    It seems to me that is complicating a simple operation. You can add a UserForm to your VBA project with a ListBox and a CommandButton. The code below can be added to this UserForm.
    Please Login or Register  to view this content.

    Add the following code to the button on your on the "Master". This will display the user form. Change the name of the user form to match the name of your user form.
    Please Login or Register  to view this content.
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

  4. #4
    Forum Expert snb's Avatar
    Join Date
    05-09-2010
    Location
    VBA
    MS-Off Ver
    Redhat
    Posts
    5,649

    Re: Need some help with a bit of VBA code.

    Or you can simply use a validationlist; e.g. in cell C3

    Please Login or Register  to view this content.
    in the macromodule of worksheet 'Master':

    Please Login or Register  to view this content.



  5. #5
    Registered User
    Join Date
    10-30-2011
    Location
    Havelock, NC
    MS-Off Ver
    Excel 2007
    Posts
    2

    Re: Trying to Print User-Selected Sheets from a button on one sheet.

    Thank you all for the correction and advice so far. I will try these out tomorrow at work and let you all know how it turns out.

    Again, thank you.

    rattler418

+ 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