How to add identical slicers to multiple sheets with identical Tables headers on each sheet

Marnel_Runner

New Member
Joined
Mar 27, 2019
Messages
2
Hi all

I'm new here, and have been unable to find a solution to my specific query online or in forums, so I hope somebody can help me. The problem is with Slicers. I work in construction, pricing up potential projects. We produce a 'Report' from our software and I have manipulated this data into discreet sheets, based on their area of the country, let's say South, London, North and Scotland. There are 4 sheets, each with identical Tables, but with data specific to each area. Each Table in named to match the Sheet name and area in the country, so, South, London, North and Scotland.

I have recorded the process and then tried to manipulate the code to use variables, specific to each Sheet and Table, along with the Field headers I want to filter by, but to no avail. Please help!

So... Specific data, held in identical Tables, named as the sheet name. Each sheet is named and I want to add slicers for two fields, 'Our Win %' and 'Stage', on every sheet of the workbook that has a table.

So far I have the following code, which gives me a Run-time error 5 - Invalid procedure call or argument, at the first ActiveWorkbook.SlicerCaches.Add2 statement:


Code:
Sub AddSlicers()
    
    Dim Source As String
    Dim ptName1 As String
    Dim ptName2 As String
        
    wsCount = Worksheets.Count
    
    For WSLoopCount = 3 To wsCount
        Worksheets(WSLoopCount).Select
        
        Source = "ActiveSheet.ListObjects(" & Chr(34) & ActiveSheet.Name & Chr(34) & ")"
        MsgBox Source
        
        ptName1 = Chr(34) & "Our Win % " & WSLoopCount & Chr(34)
        MsgBox ptName1
        
        ptName2 = Chr(34) & "Stage " & WSLoopCount & Chr(34)
        MsgBox ptName2
        
        ActiveSheet.Rows("1:6").Insert
        
        Range("A7").Select
[FONT=arial black]        ActiveWorkbook.SlicerCaches.Add2(Source _[/FONT]
[FONT=arial black]            , "Our Win %").Slicers.Add ActiveSheet, , ptName1, "Our Win %", 0, 0, 150, _[/FONT]
[FONT=arial black]            102[/FONT]
        ActiveWorkbook.SlicerCaches.Add2(Source _
            , "Stage").Slicers.Add ActiveSheet, , ptName2, "Stage", 0, 150, 150, 102
    Next
            
End Sub

If you are able to guide me to a worked example, or a clear description of the constituent terms and their usage, that would be great. If you are able to revise my code and explain where I have been going wrong, that would be fantastic!

I've been trying to solve this for over 11 hours now and can't find a way through.

Cheers
 

Excel Facts

Round to nearest half hour?
Use =MROUND(A2,"0:30") to round to nearest half hour. Use =CEILING(A2,"0:30") to round to next half hour.

Forum statistics

Threads
1,223,228
Messages
6,170,871
Members
452,363
Latest member
merico17

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top