+ Reply to Thread
Results 1 to 2 of 2

Help: Print Pivot Table Report TO pdf. BY Filter AS Separate Page

  1. #1
    Registered User
    Join Date
    08-30-2016
    Location
    Edmonton, Canada
    MS-Off Ver
    2016 64b
    Posts
    92

    Help: Print Pivot Table Report TO pdf. BY Filter AS Separate Page

    Hello,

    I'm in a bit of a sticky situation; I have a pivot table compiled using power query/dax and I'm now needing to print this out.

    The problem is I need to:
    - 1. Print this out by criteria/filter onto (preferrably) a pdf
    - 2. Each filter to be printed onto a separate page
    - 3. Incorporate the pivot table updating with new/changing data

    I believe VBA is how to do this and I've copy/pasted several code through google searching, but none seem to work, or I get an error of "Compile error: Expected: identifier". I am new to VBA so this could be as simple as me not classing something properly.


    An example of a script that I've tried is below.

    Thank you in advance for any help!
    ---------------------------------------------------------------------

    Sub ()
    'prints a copy of pivot table for
    'each item in page field
    'assumes one page field exists
    Application.ScreenUpdating = False
    DirectoryLocation = ActiveWorkbook.Path

    On Error Resume Next
    Dim pt As PivotTable
    Dim pf As PivotField
    Dim pi As PivotItem
    Set pt = ActiveSheet.PivotTables.Item(1)
    For Each pf In pt.PageFields
    For Each pi In pf.PivotItems
    pt.PivotFields(pf.EmployeeName).CurrentPage = pi.EmployeeName

    Columns("B:B").ColumnWidth = 8.14

    Name = DirectoryLocation & "\" & Range("B2").Value & ".pdf"

    ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:=Name _
    , Quality:=xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas _
    :=False, OpenAfterPublish:=False

    Next
    Next pf

    Application.ScreenUpdating = True

    ----------------------------------------------------

  2. #2
    Forum Expert dflak's Avatar
    Join Date
    11-24-2015
    Location
    North Carolina
    MS-Off Ver
    365
    Posts
    7,920

    Re: Help: Print Pivot Table Report TO pdf. BY Filter AS Separate Page

    Ac couple of things:
    1. Use code tags. I'm surprised an admin hasn't jumped on you yet for this.
    2. Attach a sample workbook with non-sensitive data. I doubt anyone is going to take the time to set up a workbook to test out the issue.

    A quick look at the code indicates that pt.PivotFields(pf.EmployeeName).CurrentPage = pi.EmployeeName might be the issue. I am not familiar with .CurrentPage. I'll have to look it up. That is the another issue with the write-up. Knowing the kind of error is a bit of a help, but knowing on which line it occurs is a much bigger help.
    One spreadsheet to rule them all. One spreadsheet to find them. One spreadsheet to bring them all and at corporate, bind them.

    A picture is worth a thousand words, but a sample spreadsheet is more likely to be worked on.

+ 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. Pivot Table with report filter
    By Jayakumar1313 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 08-09-2016, 01:14 PM
  2. Replies: 0
    Last Post: 07-14-2016, 03:51 PM
  3. Filter in Pivot Table's Report Filter
    By mxlew in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 06-10-2015, 12:46 AM
  4. [SOLVED] How to set a 'Date Filter' on a field in the 'Report Filter' section of a Pivot Table?
    By Rhino_dance in forum Excel Charting & Pivots
    Replies: 7
    Last Post: 03-28-2013, 11:01 AM
  5. Macro to print each name in a pivot table filter drop-down on a seperate page
    By Tamarissa in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 11-13-2012, 02:28 PM
  6. Replies: 0
    Last Post: 11-18-2011, 07:31 AM
  7. Place a number filter on a report filter in a pivot table
    By reuben.doetsch in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 11-01-2010, 12:41 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