Public Sub UpdateChart()
Dim ChtObj As ChartObject
Dim PriceType As Long
Set ChtObj = ActiveSheet.ChartObjects(1)
Application.ScreenUpdating = False
PriceType = ActiveSheet.Cells(13, 20).Value
If PriceType = 1 Then
With ChtObj.Chart.SeriesCollection(1)
.Values = ActiveSheet.Range("$C$771:$C$1475")
.MarkerBackgroundColorIndex = 1
.MarkerBackgroundColorIndex = 4
End With
ChtObj.Visible = True
ElseIf PriceType = 2 Then
With ChtObj.Chart.SeriesCollection(1)
.Values = ActiveSheet.Range("$D$771:$D$1475")
.MarkerForegroundColorIndex = 1
.MarkerBackgroundColorIndex = 5
End With
ChtObj.Visible = True
ElseIf PriceType = 3 Then
With ChtObj.Chart.SeriesCollection(1)
.Values = ActiveSheet.Range("$E$771:$E$1475")
.MarkerForegroundColorIndex = 1
.MarkerBackgroundColorIndex = 3
End With
ChtObj.Visible = True
ElseIf PriceType = 4 Then
With ChtObj.Chart.SeriesCollection(1)
.Values = ActiveSheet.Range("$I$771:$I$1475")
.MarkerForegroundColorIndex = 1
.MarkerBackgroundColorIndex = 9
End With
ChtObj.Visible = True
ElseIf PriceType = 5 Then
With ChtObj.Chart.SeriesCollection(1)
.Values = ActiveSheet.Range("$F$771:$F$1475")
.MarkerForegroundColorIndex = 1
.MarkerBackgroundColorIndex = 7
End With
ChtObj.Visible = True
ElseIf PriceType = 6 Then
With ChtObj.Chart.SeriesCollection(1)
.Values = ActiveSheet.Range("D$771:$D$1475")
.MarkerForegroundColorIndex = 1
.MarkerBackgroundColorIndex = 5
End With
ActiveChart.SeriesCollection.NewSeries
With ChtObj.Chart.SeriesCollection(2)
.Values = ActiveSheet.Range("E$771:$E$1475")
.MarkerForegroundColorIndex = 1
.MarkerBackgroundColorIndex = 3
End With
ActiveChart.SeriesCollection.NewSeries
With ChtObj.Chart.SeriesCollection(3)
.Values = ActiveSheet.Range("I$771:$I$1475")
.MarkerForegroundColorIndex = 1
.MarkerBackgroundColorIndex = 9
End With
ChtObj.Visible = True
End If
ActiveSheet.PivotTables("PivotTable3").PivotCache.Refresh
Application.ScreenUpdating = True
End Sub
|