VBA to select each slicer item AND then save each selected slicer item as a pdf?

后端 未结 2 1805
刺人心
刺人心 2021-01-15 15:25

I\'ve designed a dashboard consisting of a number of different pivot tables and pivot charts.

All of these pivot tables/charts are controlled by 1 slicer called \"S

2条回答
  •  时光说笑
    2021-01-15 15:42

    Sub FacultyToPDF()
    
    Dim wb As String
    Dim sh As Worksheet
    Dim fname As String
    Dim location As String
    Dim sI As SlicerItem, sI2 As SlicerItem, sC As SlicerCache
    Dim index As Integer
    Const PrintRange = "Print_Area"    
    
    fPath = "C:\Users\xiaz01\Desktop\Special Project\PDF"
    Set sC = ActiveWorkbook.SlicerCaches("Slicer_billing_phys_name")    
    
    
    For Each sI In ActiveWorkbook.SlicerCaches("Slicer_billing_phys_name").SlicerCacheLevels(1).SlicerItems
        ActiveWorkbook.SlicerCaches("Slicer_billing_phys_name").VisibleSlicerItemsList = Array(sI.Name)
        fname = Range("B1").Text & Format(Date, " yy-mm-dd") & ".pdf"
        Range(PrintRange).ExportAsFixedFormat Type:=xlTypePDF, Filename:=fPath & "\" & fname
    Next    
    
    End Sub
    

提交回复
热议问题