run code every time selection in slicer is selected
<p>Hoping for some guidance. I want to run my existing code in a worksheet every time the a new selection is selected in excel slicer. I am new to code so if someone does respond, please be specific as to where i put the code. See below. The last part of the code is my attempt at running the code if a new selection is made but it does not work and returns an error. </p>

<pre><code>    Sub ConditionalFormatting()

End Sub


Set a = Sheets("Pivot")

i = 6 'row
j = 6 'column
Do Until a.Cells(4, j) = "Grand Total" 'tells code to continue the code until it finds Grand Total
    j = j + 1
Loop
j = j - 1
vArr = Split(Cells(1, j).Address(True, False), "$")
a.Cells(1, 15) = vArr
Do Until a.Cells(i, 5) = ""
    a.Range("F" &amp; i &amp; ":" &amp; a.Cells(1, 15).Value &amp; i).Select
    Selection.FormatConditions.AddColorScale ColorScaleType:=3
    i = i + 1
Loop
a.Cells(1, 15) = ""



Private Sub Workbook_SheetPivotTableChangeSync(ByVal Sh As Object, ByVal Target As PivotTable)
    Application.Run ("'Top 95 Data Update.xlsb'!ConditionalFormatting")


End Sub
</code></pre>