Chartの要素

🟢 Excel VBA
投稿日: 2026年4月13日8:59
maxChart = ActiveSheet.ChartObjects.Count
With ActiveSheet.Shapes.AddChart2.Chart
        .ChartType = xlLine
        .SetSourceData Range(Cells(DATAINIROW, DATAINICLM), Cells(DATAENDROW, DATAENDCLM))
End With
Set chartObj = ActiveSheet.ChartObjects(maxChart + 1)
With chartObj
        .Width = 800
        .Height = 520
        .Name = "ChartPref"
        With .Chart
            .HasTitle = True
            .ChartTitle.Caption = "タイトル"
    cntLine = .FullSeriesCollection.Count
       For i = 1 To cntLine
        If InStr(.FullSeriesCollection(i).Name, "広島") <> 0 Then
      .FullSeriesCollection(i).Format.Line.ForeColor.RGB = RGB(248, 58, 221)
                      .FullSeriesCollection(i).Format.Fill.ForeColor.RGB = RGB(248, 58, 221)
Sheetの
 チャートオブジェクトの
  チャートの
    シリーズコレクションの数を取得して
        その数をLoopすると
          一つずつ処理可能。
            (色の設定とか)
No Comment