|
Sub 画图() ' 画图 Macro
我录了一段宏进行图表生产,然后把里面的参数改成循环的方式进行了批量处理,但是生产的图都是乱排列的,请教各位达人怎么样改进代码使图表可以排列成一行?谢谢
Dim i As Integer
For i = 1 To 100
If Cells(4, i) <> "" Then
i = i + 1
Cells(20, i).Select
ActiveSheet.Shapes.AddChart.Select
ActiveChart.ChartType = xlBarClustered
ActiveChart.SetSourceData Source:=Sheets("流动性_03").Range(Cells(4, i), Cells(8, i))
ActiveChart.Axes(xlCategory).Select
ActiveChart.PlotArea.Select
ActiveChart.SeriesCollection.NewSeries
ActiveChart.SeriesCollection(2).Name = "=流动性_03!$B$10:$B$14"
ActiveChart.SeriesCollection(2).XValues = Sheets("流动性_03").Range("$A$10:$A$14")
ActiveChart.SeriesCollection(1).Name = "=""大样本分析结果"""
ActiveChart.SeriesCollection(2).Name = "=""小样本分析结果"""
ActiveChart.Axes(xlValue).MajorGridlines.Select
ActiveChart.SeriesCollection(1).Select
ActiveChart.SeriesCollection(1).ApplyDataLabels
ActiveChart.SeriesCollection(2).Select
ActiveChart.SeriesCollection(2).ApplyDataLabels
ActiveChart.SeriesCollection(2).Values = Sheets("流动性_03").Range(Cells(10, i), Cells(14, i))
ActiveWindow.SmallScroll Down:=2
ActiveChart.PlotArea.Select
End If
Next i
End Sub
|
|