Selecting a powerpivot slicer value based on a cell value

HamidR

New Member
Joined
Feb 25, 2015
Messages
1
Hello, this is my first post, hopefully someone will be able to help. I'm having some issues in automating a PowerPivot slicer using vba. What I am trying to do is have the slicer update and only select what is in a certain cell.
So for example assuming the cell was A3 then whatever was typed in A3 that's what would get updated in the slicer.
My values in my slicer are just numbers. The code I currently have (which i found online doesn't work) throws a run time error is below. The formula name of the slicer is "Newnumber" and the cell I would like it to look at and then update is cell A3.
Many thanks


<code style="margin: 0px; padding: 0px; border: 0px; font-family: Consolas, Menlo, Monaco, 'Lucida Console', 'Liberation Mono', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', monospace, sans-serif; white-space: inherit;"> Public Sub Worksheet_Change(ByVal Target As Range)
Dim sC As SlicerItem
Application
.EnableEvents = False
If Not Intersect(Target, Range("A3")) Is Nothing Then
With ActiveWorkbook.SlicerCaches("Slicer_Newnumber")
.ClearManualFilter
For Each sC In .SlicerItems
sC
.Selected = UCase(SI.Value) = UCase(Range("A3").Value)
Next sC
End With
End If
ExitSub
:
Application
.EnableEvents = True
End Sub</code>
 

Excel Facts

Pivot Table Drill Down
Double-click any number in a pivot table to create a new report showing all detail rows that make up that number

Forum statistics

Threads
1,214,919
Messages
6,122,260
Members
449,075
Latest member
staticfluids

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