在合并的单元格中创建Sparkline,引用为" Section3"。我想要参考Sparkline图表的数据位于命名字段" TBLCOL3"。
<Sub Macro14()
Dim ws As Worksheet
Dim i As Integer
Dim rng3 As Range
Dim rng4 As Range
Set ws = ActiveSheet
i = 3
Set rng3 = ActiveSheet.Range("Section" & i)
Set rng4 = ActiveSheet.Range("TBLCOL" & i)
rng3.SparklineGroups.Add Type:=xlSparkLine, SourceData:=CStr(rng4.Address)
Selection.SparklineGroups.Item(1).SeriesColor.ThemeColor = 5
Selection.SparklineGroups.Item(1).SeriesColor.TintAndShade = -0.499984740745262
Selection.SparklineGroups.Item(1).Points.Negative.Color.ThemeColor = 6
Selection.SparklineGroups.Item(1).Points.Negative.Color.TintAndShade = 0
Selection.SparklineGroups.Item(1).Points.Markers.Color.ThemeColor = 5
Selection.SparklineGroups.Item(1).Points.Markers.Color.TintAndShade = - _
0.499984740745262
Selection.SparklineGroups.Item(1).Points.Highpoint.Color.ThemeColor = 5
Selection.SparklineGroups.Item(1).Points.Highpoint.Color.TintAndShade = 0
Selection.SparklineGroups.Item(1).Points.Lowpoint.Color.ThemeColor = 5
Selection.SparklineGroups.Item(1).Points.Lowpoint.Color.TintAndShade = 0
Selection.SparklineGroups.Item(1).Points.Firstpoint.Color.ThemeColor = 5
Selection.SparklineGroups.Item(1).Points.Firstpoint.Color.TintAndShade = _
0.399975585192419
Selection.SparklineGroups.Item(1).Points.Lastpoint.Color.ThemeColor = 5
Selection.SparklineGroups.Item(1).Points.Lastpoint.Color.TintAndShade = _
0.399975585192419
End Sub>
我使用i = 3,因为这是我将要创建的循环的基础。我已经创建了遍历每个表的代码,并在我的表右侧创建了一个合并的单元格2列,将合并的单元命名为&#34; Section&#34; &安培;一世。然后在我的表中找到第3个数据列并命名为&#34; TBLCOL&#34; &安培;岛
这是拼图的最后一部分 - 任何反馈都会非常感激。上面的代码返回全局失败错误消息。我知道这对应于变量引用但我无法自行解决。
编辑:修改了第一条评论,并添加了在&#34;记录宏&#34;
期间收集的格式