+ Reply to Thread
Results 1 to 3 of 3

VBA code for printing from single sheet based on value

  1. #1
    Registered User
    Join Date
    01-25-2024
    Location
    Netherlands
    MS-Off Ver
    Office 365
    Posts
    2

    VBA code for printing from single sheet based on value

    Hello,

    I've received this question actually from my co-worker, but I did not manage to solve it myself.
    The issue is rather simple, but I cannot manage to find the solution for it.

    I have a single sheet with numbers on it, or amounts of trolleys and shelves as we call it in a table. Attached to these numbers are seperate pages to be printed on the same sheet, which shows each branch with the amounts from the table.
    Some branches have 10 trolleys to be collected, some branches have no trolleys to be collected.
    Right now, my co-worker prints out the sheet, and receives 64 pages, but we want this reduced, based on the numbers in the table, as we do not want to print the pages which show a 0 on the page.

    I've tried to make a small vba code, based on the cell-value, so when this shows a zero, it should not print the range (of the page). This did not work at all.

    So what I need is a VBA code that prints the pages where trolleys are to be collected.
    If any value is more than zero on:

    0 TAG5 Leeg



    0 TAG5 Fust



    0 TAG5 Kapot


    then it should print the range of the page.

    If you can make a code for one page, and I need to manually add each page to the code, that is also fine.
    I hope this is clear for any of you guys and can help me sort this out!

    Thanks,
    Sam
    Attached Files Attached Files
    Last edited by Sambabal; 01-26-2024 at 04:42 AM.

  2. #2
    Registered User
    Join Date
    01-25-2024
    Location
    Berlin, Germany
    MS-Off Ver
    2007
    Posts
    22

    Re: VBA code for printing from single sheet based on value

    I have created two macros.
    First macro selects all the pages that will be printed.
    Please Login or Register  to view this content.
    Second macro selects and prints selected pages

    Please Login or Register  to view this content.
    There are two buttons on the top that you can run for selecting and printing.
    Please test the attached file to see if this is what you want.
    Attached Files Attached Files

  3. #3
    Registered User
    Join Date
    01-25-2024
    Location
    Netherlands
    MS-Off Ver
    Office 365
    Posts
    2

    Re: VBA code for printing from single sheet based on value

    Hi Kowon,

    I've got a remark regarding the macro you'd created for me.
    If the amount of pages to be printed is at 23 or higher, the following error appears:
    error 1004 method range of object _global failed

    We didn't have this many pages until yesterday, so that's why I've come up with this now.

    Would you be able to have a look for me please?

    Thanks,
    Sam

+ 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. How do I print a single worksheet over 2 sides of a sheet when printing.
    By tweacle in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 07-17-2021, 11:14 PM
  2. Replies: 2
    Last Post: 04-17-2021, 05:08 AM
  3. Printing single sheet to .pdf then embedding the file. (renaming OLEObject?)
    By Canuckle777 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-14-2013, 12:56 PM
  4. Macro to prevent printing specific sheet based on cell value in another sheet
    By dbrady01 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-24-2013, 04:23 PM
  5. Separately printing multiple tables from a single sheet
    By NewDawn999 in forum Excel General
    Replies: 9
    Last Post: 04-01-2013, 09:32 AM
  6. Printing only one single sheet
    By ghorpade.naveen in forum Excel General
    Replies: 2
    Last Post: 02-04-2011, 06:12 AM
  7. [SOLVED] I want to put page no in a single sheet in excel while printing
    By ravi in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 09-21-2005, 09:05 AM

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