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
ChtObj.Chart.SeriesCollection(1).Values = ActiveSheet.Range("$C$771:$C$1475")
ChtObj.Chart.SeriesCollection(1).MarkerBackgroundColorIndex = 1
ChtObj.Chart.SeriesCollection(1).MarkerBackgroundColorIndex = 4
ChtObj.Visible = True
Else
If PriceType = 2 Then
ChtObj.Chart.SeriesCollection(1).Values = ActiveSheet.Range("$D$771:$D$1475")
ChtObj.Chart.SeriesCollection(1).MarkerForegroundColorIndex = 1
ChtObj.Chart.SeriesCollection(1).MarkerBackgroundColorIndex = 5
ChtObj.Visible = True
Else
If PriceType = 3 Then
ChtObj.Chart.SeriesCollection(1).Values = ActiveSheet.Range("$E$771:$E$1475")
ChtObj.Chart.SeriesCollection(1).MarkerForegroundColorIndex = 1
ChtObj.Chart.SeriesCollection(1).MarkerBackgroundColorIndex = 3
ChtObj.Visible = True
Else
If PriceType = 4 Then
ChtObj.Chart.SeriesCollection(1).Values = ActiveSheet.Range("$I$771:$I$1475")
ChtObj.Chart.SeriesCollection(1).MarkerForegroundColorIndex = 1
ChtObj.Chart.SeriesCollection(1).MarkerBackgroundColorIndex = 9
ChtObj.Visible = True
Else
If PriceType = 5 Then
ChtObj.Chart.SeriesCollection(1).Values = ActiveSheet.Range("$F$771:$F$1475")
ChtObj.Chart.SeriesCollection(1).MarkerForegroundColorIndex = 1
ChtObj.Chart.SeriesCollection(1).MarkerBackgroundColorIndex = 7
ChtObj.Visible = True
Else
If PriceType = 6 Then
ChtObj.Chart.SeriesCollection(1).Values = ActiveSheet.Range("D$771:$D$1475")
ChtObj.Chart.SeriesCollection(1).MarkerForegroundColorIndex = 1
ChtObj.Chart.SeriesCollection(1).MarkerBackgroundColorIndex = 5
ChrtObj.Chart.SeriesCollection.Add
ChtObj.Chart.SeriesCollection(2).Values = ActiveSheet.Range("E$771:$E$1475")
ChtObj.Chart.SeriesCollection(2).MarkerForegroundColorIndex = 1
ChtObj.Chart.SeriesCollection(2).MarkerBackgroundColorIndex = 3
ChrtObj.Chart.SeriesCollection.Add
ChtObj.Chart.SeriesCollection(3).Values = ActiveSheet.Range("I$771:$I$1475")
ChtObj.Chart.SeriesCollection(3).MarkerForegroundColorIndex = 1
ChtObj.Chart.SeriesCollection(3).MarkerBackgroundColorIndex = 9
ChtObj.Visible = True
End If
End If
End If
End If
End If
End If
ActiveSheet.PivotTables("PivotTable3").PivotCache.Refresh
Application.ScreenUpdating = True
End Sub
|