VBA - Slicers

thomas819

New Member
Joined
Nov 23, 2020
Messages
36
Office Version
  1. 2019
Platform
  1. Windows
Hello all,
I would like to create macro with this function.
I have pivot table which contains two slicers.
Values from pivot table are in range C3:C6
When I selected a any item from 1.slicer except ("Manufacture"), I need reset 2.slicer (ClearManualFilter) and hide 2.slicer.
When I will select from 1.slicer item "Manufacture", I need also reset 2.slicer (ClearManualFilter) and show 2.slicer.

My train of thoughts is as follow:
VBA Code:
Sub Worksheet_Change(ByVal Target As Range)
    If Intersect(Target, Range("C3:C6")) Is Nothing Then
        If ActiveWorkbook.SlicerCaches("1.slicer").VisibleSlicerItemsList = Array("[source].[Name].&[Manufacture]") Then
            ActiveWorkbook.SlicerCaches("2.slicer").ClearManualFilter
            ActiveWorkbook.SlicerCaches("2.slicer").Show    'I dont know sorrect syntax for this purpose
        Else
            ActiveWorkbook.SlicerCaches("2.slicer").ClearManualFilter
            ActiveWorkbook.SlicerCaches("2.slicer").Hide    'I dont know sorrect syntax for this purpose
        End If
    End If
End Sub

For some reason I always got error for mismatch.

I will appreciate any help :)
Thank you in advance.
 

Excel Facts

How to show all formulas in Excel?
Press Ctrl+` to show all formulas. Press it again to toggle back to numbers. The grave accent is often under the tilde on US keyboards.

Forum statistics

Threads
1,214,932
Messages
6,122,332
Members
449,077
Latest member
jmsotelo

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