+ Reply to Thread
Results 1 to 8 of 8

VBA program to adjust Print Area on ever changing Pivot Table

  1. #1
    Registered User
    Join Date
    08-28-2013
    Location
    USA
    MS-Off Ver
    Excel 2007
    Posts
    3

    VBA program to adjust Print Area on ever changing Pivot Table

    Hi Team, I built some pivots for a friend that enables him to filter by different manufactures / locations, etc. to obtain different result that he needs for ordering supplies, shipping product to, etc. However, each time that the pivot is adjusted, i.e. by filtering, the print area needs to be adjusted. I am trying to have this file as user friendly as possible so the user does not need to go in and adjust the print area every-time he adjusts the pivot. Can someone help me in setting up a macro "Print Button" on each tab that will auto adjust the print area and print?

    I have included the file below

    Thanks in Advance -
    Attached Files Attached Files
    Last edited by jonlisa11; 09-03-2013 at 01:54 PM.

  2. #2
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: VBA program to adjust Print Area on ever changing Pivot Table

    Hi jonlisa11

    Welcome to the Forum!

    You can try this Code...let me know of issues...
    Please Login or Register  to view this content.
    To Print the Worksheets change these lines of Code from
    Please Login or Register  to view this content.
    to
    Please Login or Register  to view this content.
    John

    If you have issues with Code I've provided, I appreciate your feedback.

    In the event Code provided resolves your issue, please mark your Thread as SOLVED.

    If you're satisfied by any members response to your issue please use the star icon at the lower left of their post.

  3. #3
    Registered User
    Join Date
    08-28-2013
    Location
    USA
    MS-Off Ver
    Excel 2007
    Posts
    3

    Re: VBA program to adjust Print Area on ever changing Pivot Table

    Hi Jaslake, I am not sure I am copying the code and inserting in my file correctly. Here is the file with your code inserted - i am really new at this VBA stuff.

    Thank you for the response -
    Attached Files Attached Files

  4. #4
    Valued Forum Contributor fredlo2010's Avatar
    Join Date
    07-04-2012
    Location
    Miami, United States
    MS-Off Ver
    Excel 365
    Posts
    762

    Re: VBA program to adjust Print Area on ever changing Pivot Table

    Hello jonlisa,

    See if this code works.

    Place the following code in a module in the workbook

    Please Login or Register  to view this content.
    Now under the "ThisWorkbook" module place this one

    Please Login or Register  to view this content.
    That's it you don't have to do anything else just print normally. Every time you print the code will be activated.

    I have attached a sample so you know where the codes are supposed to go. Attachment 262458

    Thanks

  5. #5
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,481

    Re: VBA program to adjust Print Area on ever changing Pivot Table

    If you hook into the SheetPivotTableUpdate event of the Thisworkbook object you can set the print area when the table updates and the user can use the built in print function, so no need for any extra button to press.

    Please Login or Register  to view this content.
    biggest issue is deciding how each PT should be printed. All on one page or 1 page wide etc.
    Cheers
    Andy
    www.andypope.info

  6. #6
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: VBA program to adjust Print Area on ever changing Pivot Table

    Hi jonlisa11

    Attached is your original Sample File with the Code embedded. I've assigned CTRL + x as a keyboard shortcut.
    Attached Files Attached Files

  7. #7
    Registered User
    Join Date
    08-28-2013
    Location
    USA
    MS-Off Ver
    Excel 2007
    Posts
    3

    Re: VBA program to adjust Print Area on ever changing Pivot Table

    Hi Jaslake, I copied your code into my working Excel file. but for some reason i cannot get your CTRL+X option to work. I can only run it by clicking on run macro, what am i missing?

    Thanks
    JL

  8. #8
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: VBA program to adjust Print Area on ever changing Pivot Table

    Hi jonlisa11

    You need to assign the Shortcut to that Macro. Press alt + F8. Select Print_Pivots. Select Options. Place an x in the Box next to CTRL +. Select OK.

+ 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. Auto Adjust Print Area
    By bgreen in forum Excel General
    Replies: 7
    Last Post: 01-02-2014, 01:42 AM
  2. Adjust Print Area Macro
    By Traymond in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 06-13-2009, 03:16 PM
  3. Macro to Adjust Print Area
    By JustinL in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 07-16-2008, 09:30 PM
  4. Automatically Changing the Print Area for Pivot Tables
    By Amy in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 07-13-2006, 05:45 PM
  5. Replies: 2
    Last Post: 12-28-2005, 01:10 PM

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