Excel VBA - 如何为图表系列设置线条样式? [英] Excel VBA - How do you set line style for chart series?

查看:2027
本文介绍了Excel VBA - 如何为图表系列设置线条样式?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想根据用户指定的特定标准,图表中的绘制线为实线,圆点或正方形点。我可以成功地使用一个宏来设置线的颜色和标记样式,但我似乎找不到的对象,其中包含绘制线样式属性的值。我已经尝试使用记录宏功能,但是更改属性窗口中的线条样式不会显示在代码中,并且运行记录的宏没有效果。

I would like the plot lines in a chart to be either solid, circle dot, or square dot based upon a certain criteria specified by the user. I can successfully set the line color and marker style for the plot using a macro, but I cannot seem to find the object which holds the value for the plot line style property. I have tried using the record macro function, but changing the line style in the properties windows does not show up in the code, and running the recorded macro has no effect.

非常感谢任何帮助。

推荐答案

创建一个包含255个数据系列的图表,运行代码(并根据需要进行其他格式化) 。然后将其另存为模板。

Create a chart with 255 data series, run the code (and do other formatting as necessary). Then save it as a template.

Sub dd()

Dim wb As Workbook
Set wb = Application.ActiveWorkbook

Dim myChart As Chart
Set myChart = wb.Charts("Chart5")

Dim mySeries As series

For Each mySeries In myChart.SeriesCollection
    mySeries.Format.Line.Weight = 1#
Next

End Sub

这篇关于Excel VBA - 如何为图表系列设置线条样式?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆