Results 1 to 5 of 5

VBA to loop through slicer option and export each to PDF

Threaded View

  1. #1
    Registered User
    Join Date
    11-23-2016
    Location
    London
    MS-Off Ver
    2016
    Posts
    1

    VBA to loop through slicer option and export each to PDF

    Hi

    I am trying to write a VBA that will take my sheet through each slicer option and print each country to an individual PDF. The first part seems to work (and go through each slicer option) but I am struggling to get it to save to PDF with the variable file name.

    Any help would be really useful. Thanks in advance.

    Here is the code I am using currently:

    Sub PrintAllCountriesToPDF()
    
    Dim sI As SlicerItem, sI2 As SlicerItem, sC As SlicerCache
    
    Set sC = ActiveWorkbook.SlicerCaches("Slicer_Country")
    
    With sC
    
        For Each sI In sC.SlicerItems
    
            sC.ClearManualFilter
    
            For Each sI2 In sC.SlicerItems
                If sI.Name = sI2.Name Then sI2.Selected = True Else: sI2.Selected = False
            Next
            
            Dim FName           As String
            Dim FPath           As String
         
        FPath = "C:\Users\kalexa03\Documents\CaratDashboardTest\"
        FName = "&sI.Name"
            
           ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:= _
            "FPath & " \ " & FName & .pdf", Quality:=xlQualityStandard, _
            IncludeDocProperties:=True, IgnorePrintAreas:=False, OpenAfterPublish:= _
            False
       Next
       End With
       
    
    End Sub
    Last edited by JBeaucaire; 11-23-2016 at 01:07 PM. Reason: Added missing CODE tags. Please read and follow the Forum Rules, link above in the menu bar. Thanks.

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Loop through an autofilter and export a PDF for each option
    By Paulcbanks in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-20-2016, 04:26 PM
  2. Slicer Selection loop is very slow!
    By barowan in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-04-2016, 10:09 AM
  3. Ribbon is missing slicer option
    By stephme55 in forum Excel Charting & Pivots
    Replies: 0
    Last Post: 01-11-2016, 06:25 PM
  4. Replies: 0
    Last Post: 09-10-2015, 08:25 AM
  5. Code to loop through pvt slicer very slow
    By newbi004 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 01-09-2014, 02:08 PM
  6. 'select all' option in slicer
    By Paul-NYS in forum Excel Charting & Pivots
    Replies: 2
    Last Post: 12-24-2012, 09:23 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