Consulting

Results 1 to 2 of 2

Thread: Trying to Shorten/Simplify some Code to Make it Easier to Apply To Other Workbooks

  1. #1

    Trying to Shorten/Simplify some Code to Make it Easier to Apply To Other Workbooks

    Hello everyone. Trying to find some help. Theattached workbook has slicers. A contributor from another forum came up with a solution that allows me to hide the irrelevant ones when not in use by treating them as shapes. It works greatfor THIS workbook, but is difficult for me to apply to OTHER workbooks that haveadditional slicers due to my limited VBA knowledge.Wondering if there's a way to simplify it.Thanks everyone for your help.Let me know if anything further is needed.
    Attached Files Attached Files

  2. #2
    Distinguished Lord of VBAX VBAX Grand Master xld's Avatar
    Joined
    Apr 2005
    Posts
    24,907
    Location
    Maybe this

    Private Sub Worksheet_PivotTableUpdate(ByVal Target As PivotTable)
    Dim shp As Shape
    Dim shpName As String
        
        With Me
        
            For Each shp In .Shapes
        
                shpName = shp.Name
                If shp.Type = msoSlicer Then _
                    shp.Visible = Not .Parent.SlicerCaches("Slicer_" & shp.Name).SlicerItems.Item(1).Value = "N/A"
            Next shp
        End With
    End Sub
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •