为图表中的每个系列格式化数据标签 [英] Format data labels for each series in a chart

查看:375
本文介绍了为图表中的每个系列格式化数据标签的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图找出一种有效的方式,无论是VBA还是不,格式化我的线图上的数据标签。

I am trying to figure out an efficient way, either VBA or not, to format the data labels on a line graph I have.

图表应在每个系列的最右侧数据标签上显示系列名称,而其余数据标签为空白。

The graph should present the series name at the right most data label, for each series, while the remaining data labels are blank.

目前我只是通过每个系列添加数据标签,然后单独格式化每个单独的数据标签 - 但是当我连接多个点,除了几个系列,这是慢。

Currently I just add data labels through each series, and then format each individual data label separately - but this is slow when I have series with multiple points, in addition to several series.

有任何建议吗?感谢

推荐答案

您可以使用VBA或直接进行。

You can do this with VBA or directly.

假设 sc 是对 SeriesCollection ,使用

Dim isr As Integer, nsr As Integer
nsr = sc.Count
Dim sr As Series
Dim dp As Point
Dim dl As DataLabel
Dim fn As Font
For isr = 1 To nsr
    Set sr = sc(isr)
    Set dp = sr.Points(1)
    dp.HasDataLabel = True
    Set dl = dp.DataLabel
    dl.Text = "<your contents>"
    Set fn = dl.Characters.Font
    ' Format the data label
Next isr


b $ b

您必须替换< your contents>
请注意,您可以在此处设置对Excel范围的引用,而不是为数据标签设置固定值,这似乎是您的意图。

You have to replace "<your contents>". Note that here you can set a reference to an Excel range instead of setting a fixed value for the data label, which appears to be your intention.

有比你所做的要容易得多的事情。

There is something much easier than what you are doing.

选择单个数据点,点击目标系列,然后:1)再次点击目标数据点,或者2)按向右箭头,选择第一个数据点。

To select a single data point, click on the target series, and then: 1) click again on the target data point, or 2) press the right arrow, to select the first data point.

然后要添加数据标签,右键单击数据点,并添加数据标签。

Then to add a data label, right click on the data point, and Add Data Label.

单个数据标签,单击数据标签一次(这将选择该系列的所有数据标签,即使只有一个),然后:1)再次单击目标数据标签,或2)按向右箭头,选择第一个数据标签。

Then to select a single data label, click on the data label once (this selects all data labels for the series, even if there is only one), and then: 1) click again on the target data label, or 2) press the right arrow, to select the first data label.

然后,要编辑数据标签,请转到公式栏并键入所需的内容。随意格式化。
请注意,您可以在此处设置对Excel范围的引用,而不是直接在数据标签中输入文本,这似乎是您的意图。

Then to edit the data label, go to the formula bar and type the contents that you want. Format at will. Note that here you can set a reference to an Excel range instead of typing text directly into the data label, which appears to be your intention.

这篇关于为图表中的每个系列格式化数据标签的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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