+ Reply to Thread
Results 1 to 8 of 8

Print out certain pages in an excel sheet by PrintOut Method

Hybrid View

  1. #1
    Registered User
    Join Date
    02-12-2014
    Location
    London, England
    MS-Off Ver
    Excel 2003
    Posts
    8

    Print out certain pages in an excel sheet by PrintOut Method

    Hello there Masters of VBA..

    I have 10 pages in a worksheet of excel. I'd like to print out page 2, 4, 6 and 8 by using VBA code.

    My Question :

    Is there any script of VBA which can printout those selected pages in a sheet

    INSTEAD OF

    Having to script like this :

    Worksheets("Sheet1").PrintOut From:=2, To:=2
    Worksheets("Sheet1").PrintOut From:=4, To:=4
    Worksheets("Sheet1").PrintOut From:=6, To:=6
    Worksheets("Sheet1").PrintOut From:=8, To:=8

    Thanks in advance

  2. #2
    Registered User
    Join Date
    01-23-2014
    Location
    india
    MS-Off Ver
    Excel 2010
    Posts
    79

    Smile Re: Print out certain pages in an excel sheet by PrintOut Method

    Hey Bhayu,

    If the sheets name are Sheet1,Sheet2 respectively then you can apply loop like this

    Sub Print_Even()
    Dim i As Integer
    Dim shtnm As String
    
    For i = 1 To 8
    i = i + 1
    shtnm = "Sheet" & i
    Sheets(shtnm).PrintOut
    Next i
    end sub
    Here you can give i loop end value, uptil the sheet number you want to print


    If the suggestion helps you, then Click * below to Add Reputation
    Last edited by tanvi_kalra; 02-12-2014 at 06:23 AM.

  3. #3
    Registered User
    Join Date
    02-12-2014
    Location
    London, England
    MS-Off Ver
    Excel 2003
    Posts
    8

    Re: Print out certain pages in an excel sheet by PrintOut Method

    Dear tanvi_kalra,

    Thanks for replying. Your answer may apply to other condition, yet it hasnt answered my question.

    What if I have to print out 50 certain/selected pages of 100 pages available in sheet1?

    Any shortest script possible to write instead of writing "Worksheets("Sheet1").PrintOut From:= , To:= " for 50 times?

    Thanks in advance.

  4. #4
    Registered User
    Join Date
    01-23-2014
    Location
    india
    MS-Off Ver
    Excel 2010
    Posts
    79

    Re: Print out certain pages in an excel sheet by PrintOut Method

    Quote Originally Posted by bhayu View Post
    Dear tanvi_kalra,

    Thanks for replying. Your answer may apply to other condition, yet it hasnt answered my question.

    What if I have to print out 50 certain/selected pages of 100 pages available in sheet1?

    Any shortest script possible to write instead of writing "Worksheets("Sheet1").PrintOut From:= , To:= " for 50 times?

    Thanks in advance.
    For that you can use loop for the shortest code .. i didn't get your question clearly. Could you please clarify it again.
    Are you trying to printout many sheets from one tab only or from different tabs or both. please elaborate.

  5. #5
    Forum Guru Izandol's Avatar
    Join Date
    03-29-2012
    Location
    *
    MS-Off Ver
    Excel 20(03|10|13)
    Posts
    2,581

    Re: Print out certain pages in an excel sheet by PrintOut Method

    You may use:
    sheets(array("Sheet1", "Sheet3", "Sheet7")).printout
    for example.
    • Please remember to mark threads Solved with Thread Tools link at top of page.
    • Please use code tags when posting code: [code]Place your code here[/code]
    • Please read Forum Rules

  6. #6
    Registered User
    Join Date
    02-12-2014
    Location
    London, England
    MS-Off Ver
    Excel 2003
    Posts
    8

    Re: Print out certain pages in an excel sheet by PrintOut Method

    Dear tanvi_kalra,

    When we open a workbook of an excel file, we will see there is 3 worksheet available i.e. Sheet1, Sheet2 and Sheet3.

    In Sheet1, I have 100 pages of data. I select 50 of them to printout. Those 50 pages are not in sequence.

    Therefore, if I do it in my way, I have to write script like this, for instance :

    Worksheets("Sheet1").PrintOut From:= 1, To:= 1
    Worksheets("Sheet1").PrintOut From:= 4, To:= 4
    Worksheets("Sheet1").PrintOut From:= 8, To:= 8
    So on & so on...
    Until I have wrote down those selected 50 pages

    That's why I am asking you :

    Is there any shortest script of VBA which can print those 50 pages not sequence in Sheet1?

    Thanks for ur prompt response.

  7. #7
    Forum Guru Izandol's Avatar
    Join Date
    03-29-2012
    Location
    *
    MS-Off Ver
    Excel 20(03|10|13)
    Posts
    2,581

    Re: Print out certain pages in an excel sheet by PrintOut Method

    I did not see it was same sheet - you may try:
       Dim vPage
       For Each vPage In Array(2, 4, 6, 8)
          ActiveSheet.PrintOut from:=vPage, to:=vPage
       Next vPage

  8. #8
    Registered User
    Join Date
    02-12-2014
    Location
    London, England
    MS-Off Ver
    Excel 2003
    Posts
    8

    Re: Print out certain pages in an excel sheet by PrintOut Method

    Thanks Izandol for ur help, it is solved now.

    @tanvi_kalra : thanks for ur time participating in answering my question.

    Greet of VBA

+ 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. Print random pages in excel sheet(1) using vb.net
    By blaisexena in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-17-2013, 05:03 AM
  2. [SOLVED] Excel - print 2 pages on 1 sheet of paper
    By Jerome in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 12-20-2005, 07:15 PM
  3. Dropping blank pages from Excel Spreadsheet's Printout
    By sgluzberg in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 06-02-2005, 04:05 PM
  4. Dropping blank pages from Excel Spreadsheet's Printout-, which is very annoying
    By sgluzberg in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 05-19-2005, 11:03 AM
  5. [SOLVED] Print multiple pages per Sheet in Excel 2003
    By Chris N in forum Excel General
    Replies: 1
    Last Post: 05-03-2005, 11:06 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