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

沒有留言:

張貼留言

上市櫃營收年增率:2025.11

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