Excel精英培训网

 找回密码
 注册
数据透视表40+个常用小技巧,让你一次学会!
查看: 1752|回复: 0

请教如何把批量生成的图表排列在同一行的问题

[复制链接]
发表于 2013-8-1 14:52 | 显示全部楼层 |阅读模式
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


excel精英培训的微信平台,每天都会发送excel学习教程和资料。扫一扫明天就可以收到新教程
您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|Archiver|Excel精英培训 ( 豫ICP备11015029号 )

GMT+8, 2025-8-16 03:10 , Processed in 1.577928 second(s), 8 queries , Gzip On, Yac On.

Powered by Discuz! X3.4

Copyright © 2001-2020, Tencent Cloud.

快速回复 返回顶部 返回列表