我创建了一个多图表趋势模板,根据用户输入使用偏移功能动态更新。
我已经能够使用使用偏移函数的已定义名称标记第一个数据系列,但我无法以相同的方式标记第二个数据系列...
所以INDEX(name,1)用于在单元格中拉出数组的相关部分......
有没有办法动态创建多个文本框并链接到命名单元格?可能是这样的吗? Attaching a Textbox to a point or line on a chart in Excel/VBA
以下代码可以正常工作,但只能在一个workheert中使用一组已定义的名称。有没有办法在不同的工作表上使用命名单元格修改多个图表?
Sub Add_Text_to_point()
Dim objCht As ChartObject
Dim ws As Worksheet
' loop through sheets in this workbook
For Each ws In ThisWorkbook.Worksheets
' loop through Chartobjects in sheet
For Each objCht In ws.ChartObjects
' no need to select the chart or the series use With statement instead
With objCht.Chart.SeriesCollection(5).Points(1)
.DataLabel.Text = [Point1]
End With
With objCht.Chart.SeriesCollection(5).Points(2)
.DataLabel.Text = [Point2]
End With
With objCht.Chart.SeriesCollection(5).Points(3)
.DataLabel.Text = [Point3]
End With
With objCht.Chart.SeriesCollection(5).Points(4)
.DataLabel.Text = [Point4]
End With
With objCht.Chart.SeriesCollection(5).Points(5)
.DataLabel.Text = [Point5]
End With
With objCht.Chart.SeriesCollection(5).Points(6)
.DataLabel.Text = [Point6]
End With
With objCht.Chart.SeriesCollection(5).Points(7)
.DataLabel.Text = [Point7]
End With
With objCht.Chart.SeriesCollection(5).Points(8)
.DataLabel.Text = [Point8]
End With
With objCht.Chart.SeriesCollection(5).Points(9)
.DataLabel.Text = [Point9]
End With
With objCht.Chart.SeriesCollection(5).Points(10)
.DataLabel.Text = [Point10]
End With
Next objCht
Next ws