【发布时间】:2017-03-27 15:55:32
【问题描述】:
我在 Excel 工作簿中排列了大量数据。每组数据包含R4,C192,每张表包含十组数据。此代码创建十个图表,每个数据集一个。在我创建图表之后,它们被堆叠在另一个之上。我需要移动它们,以便它们按逻辑排列。
这是我需要做数千次的任务。我以前的解决方案结果不稳定。
Sub CreateCharts()
'This is where my variable names are stored, for titles.
Sheets("names").Select
Trial = "motor_pre"
'loop interates through subject names (k loop)
For k = 2 To 19
subj = Worksheets("names").Cells(k, 1).Text
If subj = "end" Then End
x = 1
'innerloop iterates through regions (j loop)
For j = 2 To 11
' m = j - 1
Sheets("names").Activate
Reg = Worksheets("names").Cells(j, 3).Text
start_data = Worksheets("names").Cells(j, 8)
end_data = Worksheets("names").Cells(j, 9)
Sheets(subj).Select
ActiveSheet.Shapes.AddChart2(227, xlLine).Select
ActiveChart.SetSourceData Source:=Range("'" & subj & "'!" & start_data _
& "$4:" & end_data & "$153")
ActiveChart.FullSeriesCollection(1).XValues = "='" & subj & _
"'!$H$4:$H$153"
ActiveChart.ChartTitle.Text = subj & " " & Reg
ActiveChart.Legend.Delete
Next j
Next k
End Sub
【问题讨论】:
-
.top和.left