此解决方案适用于左枢轴。您需要复制我为右侧轴心添加的两行代码。
Sub UpdatePivots()
Dim ws As Worksheet
Dim PT As PivotTable, pvtItem As PivotItem
Dim LRow As Long
For Each ws In ActiveWorkbook.Worksheets
For Each PT In ws.PivotTables
PT.PivotCache.Refresh
LRow = ws.Range("D" & ws.Rows.Count).End(xlUp).Offset(1).Row
ws.Range(ws.Cells(LRow, "D"), ws.Cells(100, "G")).Interior.Color = 11184814
Next PT
Next ws
End Sub
Sub ColorCode()
Dim Target As Range
Set Target = Application.InputBox("Select desired cell to return color code", Type:=8)
If Not Target.Count > 1 Then
MsgBox "Color Code: " & Target.Interior.Color
End If
End Sub