|
▼Yu さん:
>タイトルの通りなのですが、散布図のグラフがありまして
>同じ行、別の列の数値(グラフには含まれない)によって
>その要素の色を変えたいと思っています。
つまりこういうことでしょうか?
Sub Try1()
Dim Cht As Chart
Dim Ser As Series
Dim ss As String
Dim rngY As Range
Dim v, i As Long
Dim co As Long
Dim bo As Long
Set Cht = ActiveSheet.ChartObjects(1).Chart
Set Ser = Cht.SeriesCollection(1)
ss = Ser.Formula '系列の元データ範囲式より
Set rngY = Excel.Range(Split(ss, ",")(2)) 'Y軸データ範囲を取得
i = rngY.Column 'その行範囲の
v = rngY.Offset(, 12 - i) 'L列の値を配列に入れる
For i = 1 To UBound(v)
Select Case v(i, 1)
Case Is >= 84: co = 3: bo = 2
Case Is >= 82: co = 7: bo = 2
Case Is >= 80: co = 6: bo = 2
Case Is >= 78: co = 4: bo = 2
Case Is >= 76: co = 8: bo = 2
Case Is >= 74: co = 5: bo = 2
Case Else: co = 2: bo = 2
End Select
With Ser.Points(i)
.MarkerBackgroundColorIndex = co
.MarkerForegroundColorIndex = bo
End With
Next
End Sub
|
|