VBAで折れ線グラフを描く

touch-sp.hatenablog.com
上記記事よりさらに細かい設定を加えました。

'グラフを描く
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
    Dim graphdata As Range
     
    Set graphdata = Range("A1").CurrentRegion
    
    ActiveSheet.Shapes.AddChart2(332, xlLineMarkers).Select
    ActiveChart.SetSourceData Source:=graphdata
    ActiveChart.Location Where:=xlLocationAsNewSheet
    
    
    With ActiveChart
        '凡例を表示
        .SetElement (msoElementLegendBottom)
        '凡例のプロパティ
        .Legend.Format.TextFrame2.TextRange.Font.Fill.ForeColor.RGB = RGB(0, 0, 0)
        .Legend.Format.TextFrame2.TextRange.Font.Size = 28
        '空白セルを線で結ぶ
        .DisplayBlanksAs = xlInterpolated
        'タイトルの書式設定
        .ChartTitle.Text = "タイトル"
        .ChartTitle.Format.TextFrame2.TextRange.Font.Fill.ForeColor.RGB = RGB(0, 0, 0)
        .ChartTitle.Format.TextFrame2.TextRange.Font.Size = 32
        .ChartArea.Format.Line.Visible = msoFalse
    End With
    
    
    ActiveChart.FullSeriesCollection(3).Select
    
    With Selection
        .MarkerStyle = 8
        .MarkerSize = 8
        .MarkerBackgroundColor = RGB(0, 0, 0)
        .MarkerForegroundColor = RGB(0, 0, 0)
    End With
    
    With Selection.Format.Line
        .Visible = msoTrue
        .ForeColor.RGB = RGB(0, 0, 0)
        .Weight = 3#
        .DashStyle = msoLineSolid
    End With
    
    
    ActiveChart.FullSeriesCollection(1).Select
    
    Selection.MarkerStyle = -4142

    With Selection.Format.Line
        .Visible = msoTrue
        .ForeColor.RGB = RGB(255, 0, 0)
        .Weight = 2.5
        .DashStyle = msoLineSysDash
    End With

    
    ActiveChart.FullSeriesCollection(2).Select
    
    Selection.MarkerStyle = -4142
    
    With Selection.Format.Line
        .Visible = msoTrue
        .ForeColor.RGB = RGB(0, 0, 255)
        .Weight = 2.5
        .DashStyle = msoLineSysDot
    End With
    
    '縦軸の調整
    ActiveChart.Axes(xlValue).MajorUnit = 1
    ActiveChart.Axes(xlValue).TickLabels.Font.Size = 28
    ActiveChart.Axes(xlValue).TickLabels.Font.Color = RGB(0, 0, 0)
    
    '横軸の調整
    ActiveChart.Axes(xlCategory).TickLabels.Font.Size = 28
    ActiveChart.Axes(xlCategory).TickLabels.Font.Color = RGB(0, 0, 0)
    ActiveChart.Axes(xlCategory).TickLabels.NumberFormatLocal = "yy""年""m""月"";@"
    ActiveChart.Axes(xlCategory).MajorUnit = 1
    ActiveChart.Axes(xlCategory).MajorUnitScale = xlMonths
    ActiveChart.Axes(xlCategory).Format.Line.ForeColor.RGB = RGB(0, 0, 0)
    
    'プロットエリア塗りつぶし
    ActiveChart.PlotArea.Format.Fill.ForeColor.RGB = RGB(255, 255, 204)
    ActiveChart.PlotArea.Format.Line.ForeColor.RGB = RGB(0, 0, 0)
    

'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''