Results 1 to 11 of 11

vba to print the last 3 pages of a worksheet or less if document doesn't exceed 3 pages

Threaded View

  1. #1
    Valued Forum Contributor
    Join Date
    03-17-2007
    Location
    Michigan
    MS-Off Ver
    Excel 2021
    Posts
    974

    vba to print the last 3 pages of a worksheet or less if document doesn't exceed 3 pages

    Hello, I found the following code online to print an excel worksheet starting with printing the last page first to the first initial page. So not sure this can be edited to do what I need or not but this is what I'm hoping to accomplish. I have a worksheet that has code that will filter automatically notes based on an account number. These notes are listed by date and can range from 1 page to 15 or more. Ideally, I would like a macro when activated to only print the last 3 pages of these notes or if if there aren't 3 pages to print then those remaining pages; i.e. 1 or 2 pages. So for further clarification if there would be 11 pages to print I would only want pages 11, 10, & 9 to print out in that order. If the filtered data would only result in 2 pages to print then it would just print page 2 and page 1. If filtered data has only 1 page to print it would just print the 1 page. I would also want this to print out in black and white so no conditional formatting colors should be seen when printed if possible. Any assistance would be greatly appreciated.

    Code I found online:
    Sub ReversePrint()
    Dim xPages As Long
    xPages = ExecuteExcel4Macro("GET.DOCUMENT(50)")
    For xIndex = xPages To 1 Step -1
        Application.ActiveSheet.PrintOut from:=xIndex, To:=xIndex
    Next
    'I found this for the black white portion but not sure if this is correct spot to put it?
    Worksheets("Note").PageSetup.BlackAndWhite = True
    End Sub
    Last edited by lilsnoop; 07-28-2023 at 08:10 AM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Excel VBA to print specific pages from multiple sheets into one document
    By moxygrl88 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-17-2021, 04:11 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] Macro to Print numbered pages of same document
    By Patish in forum Word Formatting & General
    Replies: 2
    Last Post: 03-19-2019, 03:41 PM
  4. Replies: 1
    Last Post: 03-24-2016, 05:28 PM
  5. Replies: 5
    Last Post: 12-15-2014, 05:45 PM
  6. Replies: 0
    Last Post: 01-21-2013, 07:56 PM
  7. Replies: 1
    Last Post: 02-24-2006, 09:45 AM

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