Excel .Printout using a variable

Posted on 2011-10-27
Last Modified: 2012-05-12
I have 2 command buttons, one to print all of the worksheets in a workbook, and another to print the worksheets the user has selected in a multiselect listbox. The Print All code works fine: Worksheets(Array("ActCorpCkReq", "KSI Check req", "NON_VEBA Reti East Ck Req","Retirees VPS")).PrintOut

The second, I am looping through the selected items of the listbox and capturing them in a string separated by commas. So the string might look like "KSI Check req","Retirees VPS"
I want to do something like
Worksheets(Array(strSelected).printout, but I am getting error subscript out of range.
Question by:smm6809

    Author Comment

    Any help out there?
    LVL 18

    Accepted Solution

    To print the selected sheets, either group the sheets and print active sheets (default) or loop through the multi select and selet each worksheet, print, select the next worksheet, print, ....
    Another option would be to create print views and to print the view based on the selection, but, with multi-select you would need all possible combinations.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Highfive + Dolby Voice = No More Audio Complaints!

    Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

    Suggested Solutions

    Title # Comments Views Activity
    Lock cells across workbook after data entry 10 50
    Vlookup for IP 3 33
    Search multiple lines 3 25
    message box in access 4 20
    This tutorial explains how to create a series of drop-down lists that are dependent upon prior selections to guide (“force”) the user to make the correct selection and reduce data errors within Microsoft Excel. Excel 2010 was used for this tutorial;…
    You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
    This Micro Tutorial will demonstrate how to use longer labels with horizontal bar charts instead of the vertical column chart.
    This Micro Tutorial will demonstrate in Google Sheets how to use the HYPERLINK function to create live links inside your spreadsheet.

    737 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    21 Experts available now in Live!

    Get 1:1 Help Now