In der Hoffnung auf einige Hinweise. Ich möchte meinen vorhandenen Code jedes Mal in einem Arbeitsblatt ausführen, wenn eine neue Auswahl in Excel-Slicer ausgewählt wird. Ich bin neu im Code, also wenn jemand antwortet, sei bitte genau, wo ich den Code ablege. Siehe unten. Der letzte Teil des Codes ist mein Versuch, den Code auszuführen, wenn eine neue Auswahl getroffen wird, aber es funktioniert nicht und gibt einen Fehler zurück.Code jedes Mal ausführen, wenn die Auswahl im Slicer ausgewählt ist
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" & i & ":" & a.Cells(1, 15).Value & 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