+ Reply to Thread
Results 1 to 3 of 3

Excel VBA to print specific pages from multiple sheets into one document

  1. #1
    Registered User
    Join Date
    04-15-2013
    Location
    US
    MS-Off Ver
    Excel 2010
    Posts
    1

    Excel VBA to print specific pages from multiple sheets into one document

    Hi! I'm a beginner with VBA and would greatly appreciate any help or advice.

    I have a command button set up on Sheet1 that when you click the button, 3 different worksheets (all in the same workbook) will print, but will only print a certain number of pages from each worksheet. The code I have works well if you are printing to a printer, but if printing to a PDF I would like it to print the pages into one PDF instead of 3 separate PDF files (the code is creating a separate file for each worksheet because of the ActiveWindow.SelectedSheets.PrintOut code, but I don't know how to get the specific page numbers to print for each worksheet without this code).
    Sheet1 will always print all pages on worksheet.
    Sheet2 will always print page 1, but could print up to page 10 depending on the number of pages to print that is specified in cell A1 on Sheet2.
    Sheet3 might not have any pages to print, but could print up to page 10 depending on the number of pages to print that is specified in cell A1 on Sheet3.

    Code in Module:
    Sub PrintForms()

    Sheets("Sheet1").Activate
    ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True, _
    IgnorePrintAreas:=False

    Sheets("Sheet2").Activate
    PageTo = Range("A1").Value
    ActiveWindow.SelectedSheets.PrintOut From:=1, To:=PageTo, Copies:=1, Collate:=True, _
    IgnorePrintAreas:=False

    Sheets("Sheet3").Activate
    PageTo = Range("A1").Value
    ActiveWindow.SelectedSheets.PrintOut From:=1, To:=PageTo, Copies:=1, Collate:=True, _
    IgnorePrintAreas:=False

    End Sub


    Thank you so much for any help you can offer.

  2. #2
    Valued Forum Contributor
    Join Date
    09-30-2018
    Location
    Vlaams Brabant Belgium
    MS-Off Ver
    365
    Posts
    456

    Re: Excel VBA to print specific pages from multiple sheets into one document

    Hi,

    Welcome to the Forum

    First you should put code tags Forum Rule #2
    put '[ CODE ]' in front of your and '[ /CODE ]' behind your code or select the code and click on #



    if found this
    https://www.extendoffice.com/documen...s-pdf.html#one
    Please be as complete as possible in your asking so it may save use all the time to rework the solution because you didn't give all the requirements. If you have a layout in mind please work it out first so we can adapt our solution to it. Thanks.
    If you have been helped, maybe you could click the *

  3. #3
    Valued Forum Contributor
    Join Date
    09-30-2018
    Location
    Vlaams Brabant Belgium
    MS-Off Ver
    365
    Posts
    456

    Re: Excel VBA to print specific pages from multiple sheets into one document

    I also tryed this

    Please Login or Register  to view this content.
    the Array("Sheet1", "Sheet2") is the key

+ 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] Print Multiple Sheets & a dynamic number of pages
    By dabrows in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 04-22-2020, 02:01 PM
  2. Need vba code to print specific pages or all pages in a multipage UserForm
    By Pimp_mentality in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 02-24-2020, 08:13 PM
  3. [SOLVED] excel vba print specific worksheet and pages based on cell value
    By ridwan in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-15-2019, 01:38 PM
  4. VBA code to print and save specific pages in excel sheets?
    By JPSIMMON in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 02-25-2014, 03:05 PM
  5. How do I set a manual print order for pages across multiple sheets
    By Xori in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 09-20-2012, 09:48 AM
  6. Select, Count Pages and Print multiple sheets
    By jonhfl in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 03-07-2011, 12:11 PM
  7. Replies: 0
    Last Post: 08-19-2009, 12:47 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