2024年12月26日 星期四

VBA 畫垂直線

 

在折線圖上畫一個垂直線,然後是根據副軸座標來標示相同日期在主座標上


圖表名、X標籤資料位置,Y軸資料位置

Sub 巨集3(Name, rngXValues, 垂直線)

If InStr(Name, "Chart") > 0 Then

    'Range("L17").Select

    ActiveSheet.ChartObjects(Name).Activate

    ActiveChart.PlotArea.Select

    Application.CutCopyMode = False

    Application.CutCopyMode = False

    ActiveChart.SeriesCollection.NewSeries

    ActiveChart.FullSeriesCollection(2).Values = "=" & ActiveSheet.Name & "!" & 垂直線.Address ' "=工作表3!$G$2:$G$148"

    ActiveChart.FullSeriesCollection(2).Name = "=""垂直線"""

    ActiveChart.FullSeriesCollection(2).XValues = "=" & ActiveSheet.Name & "!" & rngXValues.Address   '"=工作表3!$A$149:$A$295"

    ActiveChart.Axes(xlValue).MajorGridlines.Select

    ActiveChart.ChartArea.Select

    ActiveChart.ChartType = xlColumnClustered

    ActiveChart.FullSeriesCollection(1).ChartType = xlLine

    ActiveChart.FullSeriesCollection(2).ChartType = xlColumnClustered

    ActiveChart.FullSeriesCollection(2).AxisGroup = 2

    

    End If

End Sub

沒有留言:

張貼留言

上市櫃營收年增率:202604

月年增率 115.04 上市櫃公司總營收與月年增率 月總營收 113/01 113/02 113/03 113/04 113/05 113/06 113/07 113/08 113/09 113/10 113/11 113/12 114/01 114/02 114/03 114/...