+ Reply to Thread
Results 1 to 5 of 5

Setting print area (for PDF export) based on conditions

  1. #1
    Registered User
    Join Date
    02-25-2020
    Location
    Tacoma, WA
    MS-Off Ver
    2016
    Posts
    4

    Setting print area (for PDF export) based on conditions

    I have a ton of cells and pivot charts that calculate/populate based on data from an Access Database. This data is used to create monthly reports

    Every product type has its own calculations and charts, but there are some months where a product is not produced so its specific calculations are zero and its pivot charts are blank

    I have code that generates a PDF, but I only want it to generate a PDF for the products that were produced instead of all the products, essentially excluding calculations that are zero

    This is where I am having issues

    I want to have code that determines a product has been manufactured and add that section to the print area which is used to generate the PDF

    I've tried essentially creating check boxes that used conditional IF THEN statements to set the print area, but there are too many products/combinations to create individual IF statements for each scenario

    Is there a way to tell excel this is the print area, but if this condition is met (product is created) add it to the print area? Instead of using a replacement effect like an IF statement?


    Alternatively is there a way to have excel export and the user can still select the pages via a macro?

    -Nathan

  2. #2
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Setting print area (for PDF export) based on conditions

    Hello NG1,

    Welcome to the Forum!

    I would have the macro filter the data to exclude zero counts then copy the data to another sheet. This would keep the range contiguous, which is what you want for a Print Area, and could be reused by the macro to create the individual PDF files.
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

  3. #3
    Registered User
    Join Date
    02-25-2020
    Location
    Tacoma, WA
    MS-Off Ver
    2016
    Posts
    4

    Re: Setting print area (for PDF export) based on conditions

    I have headers and pivot charts that I would like to also have exported to PDF, would the macro include those?

    I need everything to be on one PDF file, which is where I am running into the issues. I can set print area and just exclude section if I was actually printing or making individual PDF files, but I can get it to make a contiguous range if if any products aren't manufactured (instead I am left with "blank" sections)

    I also don't know how I would move sections of the sheet to another sheet if the products vary each month because I wouldn't have a standard cell only the second sheet that the data would flow too

  4. #4
    Registered User
    Join Date
    02-25-2020
    Location
    Tacoma, WA
    MS-Off Ver
    2016
    Posts
    4

    Re: Setting print area (for PDF export) based on conditions

    Alternatively (what I am now trying), can I hide the sections of data when they are blank (if statement with essentially a check box when the data is present) and print just the visible cells?

  5. #5
    Registered User
    Join Date
    02-25-2020
    Location
    Tacoma, WA
    MS-Off Ver
    2016
    Posts
    4

    Re: Setting print area (for PDF export) based on conditions

    I believe I got everything to work by if statements that hide rows when the calculations are zero, then setting it to only export the print area that is unhidden

+ 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] Setting print area based on input
    By QAChaska in forum Excel Programming / VBA / Macros
    Replies: 13
    Last Post: 12-03-2013, 01:37 PM
  2. [SOLVED] Need ‘Set Print Area’ Code for Dynamic Print Range based on Conditions
    By dosbirn in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-16-2013, 12:13 PM
  3. Setting a print area in vba
    By harveywalker in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-23-2012, 10:47 AM
  4. Setting Print Area based on Columns
    By ridonculous in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-21-2012, 07:00 PM
  5. [SOLVED] setting up the print area
    By Gina in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-13-2006, 01:15 PM
  6. Setting the print area
    By Patch61 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 04-18-2006, 11:45 AM
  7. Print Area:What would be the code for setting the print area
    By wammer in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 09-02-2005, 02:05 AM
  8. [SOLVED] Setting Print Area
    By Defoes Right Boot in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 05-18-2005, 08:06 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