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>
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>