+ Reply to Thread
Results 1 to 7 of 7

Lop through slicer until end

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    07-17-2015
    Location
    Roanoke, Virginia
    MS-Off Ver
    2010
    Posts
    173

    Lop through slicer until end

    How can I loop through a slicer called Provider on a WS called Provider Names

    The code below is what I use to execute each selection.
    (Code modified by Jerry Beaucaires - Thanks Jerry)

    Option Explicit
    
    Sub Save_As_PDF2()
    Application.ScreenUpdating = False
    
    Dim savePATH As String, saveName As String
    
    savePATH = "C:\Users\Jim\Documents\!LGTC\Network\" & Format(Date, "MM-DD-YYYY") & "\"
    saveName = ActiveSheet.Range("c2").Text & ".pdf"
    
    On Error Resume Next
    MkDir savePATH
    On Error GoTo 0
    
    Sheets(Array("Letter", "Veh License Exp", "Employee Exp", "Insurance Exp")).Select
    
    ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:=savePATH & saveName, _
         Quality:=xlQualityStandard, IncludeDocProperties:=True, _
         IgnorePrintAreas:=False, OpenAfterPublish:=False
    
    Sheets("Provider Names").Select
          Range("C7").Select
          
    Application.ScreenUpdating = True
    End Sub

  2. #2
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,653

    Re: Lop through slicer until end

    This should loop through the slicer items and call your PDF macro for each.

    Sub SlicerTest()
        
        Dim sli As SlicerItem
        
        For Each sli In ActiveWorkbook.SlicerCaches("Provider").SlicerCacheLevels(1).SlicerItems
            sli.VisibleSlicerItemsList = Array(sli.Name)
            Call Save_As_PDF2
        Next sli
        
    End Sub

    Accessing the Slicer through VBA
    Surround your VBA code with CODE tags e.g.;
    [CODE]your VBA code here[/CODE]
    The # button in the forum editor will apply CODE tags around your selected text.

  3. #3
    Forum Contributor
    Join Date
    07-17-2015
    Location
    Roanoke, Virginia
    MS-Off Ver
    2010
    Posts
    173

    Re: Lop through slicer until end

    Thanks AlphaFrog

    Run time error 1004
    Invalid Procedure Call or Argument
    @For Each sli In ActiveWorkboo. . .

  4. #4
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,653

    Re: Lop through slicer until end

    Quote Originally Posted by 3345james View Post
    Thanks AlphaFrog

    Run time error 1004
    Invalid Procedure Call or Argument
    @For Each sli In ActiveWorkboo. . .
    Look at the settings for the slicer (right click on the slicer and select slicer settings). Use the Name to use in Formulas name.

    slicer12.gif

    The slicer name

  5. #5
    Forum Contributor
    Join Date
    07-17-2015
    Location
    Roanoke, Virginia
    MS-Off Ver
    2010
    Posts
    173

    Re: Lop through slicer until end

    Same issue - settings for formula = "Slicer_Provider"

  6. #6
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,653

    Re: Lop through slicer until end

    Give this s try.

    Sub SlicerTest()
        
        Dim sli As SlicerItem
        
        With ActiveWorkbook.SlicerCaches("Slicer_Provider")
            For Each sli In .SlicerItems
                .VisibleSlicerItemsList = Array(sli.Name)
                Call Save_As_PDF2
            Next sli
        End With
        
    End Sub

  7. #7
    Forum Contributor
    Join Date
    07-17-2015
    Location
    Roanoke, Virginia
    MS-Off Ver
    2010
    Posts
    173

    Re: Lop through slicer until end

    still same error
    @.VisibleSlicerItemsList = Array(sli.Name)

+ 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. Can I Sync a Slicer to Another Slicer If....
    By Polak in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-04-2015, 12:35 AM
  2. How to protect slicer
    By chatnet in forum Excel General
    Replies: 0
    Last Post: 07-29-2014, 12:57 AM
  3. Make one slicer mirror filters of another slicer
    By IbenezPrez in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 03-28-2014, 02:00 PM
  4. how use slicer
    By Dadvar2 in forum Excel General
    Replies: 3
    Last Post: 09-05-2013, 08:29 AM
  5. Slicer Macro - unfilter another slicer on selection
    By chadheins in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 10-24-2012, 10:41 AM
  6. [SOLVED] Change Chart Title Depending on a Slicer - slicer advice
    By JungleJme in forum Excel General
    Replies: 8
    Last Post: 08-17-2012, 07:59 AM
  7. Slicer Help
    By kianhui.lim in forum Excel General
    Replies: 1
    Last Post: 03-12-2012, 12:14 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