如下图所示

每个excel图表都可以修改图表系列的线条格式。
如果要用vba修改图表系列的线条格式,可以通过Series对象的Format属性返回ChartFormat对象。
然后通过ChartFormat对象的Line属性返回LineFormat对象。
最后线条的所有属性都可以在LineFormat对象中进行设置。
如下图所示

可以通过以下vba代码设置“同比”系列的线条的属性:
Sub QQ1722187970()
Dim oWK As Worksheet
Set oWK = Excel.ActiveSheet
Dim oChartObject As ChartObject
Set oChartObject = oWK.ChartObjects(1)
Dim oChart As Chart
Dim oSeries As Series
Set oChart = oChartObject.Chart
With oChart
Set oSeries = .SeriesCollection("同比")
With oSeries.Format.Line
'复合类型
.Style = msoLineThickBetweenThin
'短划线类型
.DashStyle = msoLineDashDot
'宽度
.Weight = 2
'透明度
.Transparency = 0.5
'开始箭头类型
.BeginArrowheadStyle = msoArrowheadOval
'开始箭头粗细
.BeginArrowheadWidth = msoArrowheadNarrow
.EndArrowheadStyle = msoArrowheadTriangle
.EndArrowheadWidth = msoArrowheadWide
'有无线条
.Visible = msoCTrue
End With
End With
End Sub
如果要将图表的系列的线条设置为平滑线,可以参考下面的文章:


发表评论