+ Reply to Thread
Results 1 to 8 of 8

Create Multiple Sheets into One Output File

  1. #1
    Registered User
    Join Date
    11-22-2010
    Location
    Jax, FL
    MS-Off Ver
    Excel 2007
    Posts
    3

    Create Multiple Sheets into One Output File

    I've searched but haven't found the answer I need.

    I use a macro to read a list of names, fill in a template and produce a sheet per name (timesheets). So 25 names give me 25 timesheets. Initially I printed each sheet but now I want to create a single pdf file with the 25 sheets in it. All I've been able to come up with so far is 25 pdf's.

    Any ideas?

    Thanks for the help...ptm

  2. #2
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Create Multiple Sheets into One Output File

    This is one of those rare moments you have to actually "select" something in VBA to get it to do what you want. This code would select the three sheets noted and then print them as a single print job.

    Please Login or Register  to view this content.
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    ?None of us is as good as all of us? - Ray Kroc
    ?Actually, I *am* a rocket scientist.? - JB (little ones count!)

  3. #3
    Registered User
    Join Date
    11-22-2010
    Location
    Jax, FL
    MS-Off Ver
    Excel 2007
    Posts
    3

    Re: Create Multiple Sheets into One Output File

    Quote Originally Posted by JBeaucaire View Post
    This is one of those rare moments you have to actually "select" something in VBA to get it to do what you want. This code would select the three sheets noted and then print them as a single print job.

    Please Login or Register  to view this content.
    JB, since I will have 25 timesheets, do I need the "Sheets(Array" to list out Sheet1 .... Sheet25? I guess as I build each sheet I will have to increment the Sheet #?

    Thanks...ptm

  4. #4
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Create Multiple Sheets into One Output File

    Maybe there's a better way.

    1) are there other sheets in the workbook that WON'T be part of the print job, or is this a "print all sheets in the workbook as a single print job?"

    2) If there are others to exclude, what are those sheet names?

  5. #5
    Registered User
    Join Date
    11-22-2010
    Location
    Jax, FL
    MS-Off Ver
    Excel 2007
    Posts
    3

    Re: Create Multiple Sheets into One Output File

    There is a second sheet named "Names" where I keep the list of teachers for whom I am creating timesheets.

    ptm

  6. #6
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Create Multiple Sheets into One Output File

    The way I showed you above would give you the most control.

    If you want to try and create a macro that can dynamically decide which sheets to collect and print all together, that can be done, but is it worth the effort? You have the control you need already.

    To make it dynamic, you'd need to:

    1) Use a trick for deciding which sheets to include based on the sheet names themselves, something they all have in common, like Sheet1, Sheet2, Sheet3, etc.

    ...or

    2) Make a permanent list of the few sheet names that are always NOT print and then collect all the other sheet names dynamically except those.

  7. #7
    Registered User
    Join Date
    07-09-2009
    Location
    Australia
    MS-Off Ver
    Excel 2003
    Posts
    11

    Re: Create Multiple Sheets into One Output File

    Quote Originally Posted by JBeaucaire View Post
    This is one of those rare moments you have to actually "select" something in VBA to get it to do what you want. This code would select the three sheets noted and then print them as a single print job.

    Please Login or Register  to view this content.
    Is there anyway to modify this code to get it to save the selected sheets into a new workbook ?

    I am writing a macro that extracts sheets from a workbook and emails them, except I can only get the macro to email indivdual sheets from the workbook, but I want it to save the extracted sheets into one workbook and then email the workbook.

  8. #8
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Create Multiple Sheets into One Output File

    This line of code will copy the sheets in the array into a new unsaved workbook.
    Please Login or Register  to view this content.

+ 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