excel 用vba循环语句编程绘图 15
Sub宏1()''宏1宏''ActiveSheet.ChartObjects("图表1").ActivateActiveChart.ChartArea.CopyCells...
Sub 宏1()
'
' 宏1 宏
'
'
ActiveSheet.ChartObjects("图表 1").Activate
ActiveChart.ChartArea.Copy
Cells(5, n).Select
ActiveSheet.Paste
ActiveSheet.ChartObjects("图表 50").Activate
ActiveChart.ChartTitle.Select
Selection.Caption = "=顺河向绘图!$D$1"
ActiveChart.SeriesCollection(1).Select
ActiveChart.SeriesCollection(2).Name = "=顺河向绘图!$D$2"
ActiveChart.SeriesCollection(2).Values = "=顺河向绘图!$D$3:$D$1828"
End Sub
就是excel的列,依次从D到AH选择数据
我希望能实现第一幅图为
Selection.Caption = "=顺河向绘图!$D$1"
ActiveChart.SeriesCollection(1).Select
ActiveChart.SeriesCollection(2).Name = "=顺河向绘图!$D$2"
ActiveChart.SeriesCollection(2).Values = "=顺河向绘图!$D$3:$D$1828"
第二幅图
Selection.Caption = "=顺河向绘图!$E$1"
ActiveChart.SeriesCollection(1).Select
ActiveChart.SeriesCollection(2).Name = "=顺河向绘图!$E$2"
ActiveChart.SeriesCollection(2).Values = "=顺河向绘图!$E$3:$E$1828"
……
一直到
Selection.Caption = "=顺河向绘图!$AH$1"
ActiveChart.SeriesCollection(1).Select
ActiveChart.SeriesCollection(2).Name = "=顺河向绘图!$AH$2"
ActiveChart.SeriesCollection(2).Values = "=顺河向绘图!$AH$3:$AH$1828"
图表标题为
表面变形监测点B18顺河向位移-库水位-时间曲线
这个B18要用D1到AH1来循环,其他不变 展开
'
' 宏1 宏
'
'
ActiveSheet.ChartObjects("图表 1").Activate
ActiveChart.ChartArea.Copy
Cells(5, n).Select
ActiveSheet.Paste
ActiveSheet.ChartObjects("图表 50").Activate
ActiveChart.ChartTitle.Select
Selection.Caption = "=顺河向绘图!$D$1"
ActiveChart.SeriesCollection(1).Select
ActiveChart.SeriesCollection(2).Name = "=顺河向绘图!$D$2"
ActiveChart.SeriesCollection(2).Values = "=顺河向绘图!$D$3:$D$1828"
End Sub
就是excel的列,依次从D到AH选择数据
我希望能实现第一幅图为
Selection.Caption = "=顺河向绘图!$D$1"
ActiveChart.SeriesCollection(1).Select
ActiveChart.SeriesCollection(2).Name = "=顺河向绘图!$D$2"
ActiveChart.SeriesCollection(2).Values = "=顺河向绘图!$D$3:$D$1828"
第二幅图
Selection.Caption = "=顺河向绘图!$E$1"
ActiveChart.SeriesCollection(1).Select
ActiveChart.SeriesCollection(2).Name = "=顺河向绘图!$E$2"
ActiveChart.SeriesCollection(2).Values = "=顺河向绘图!$E$3:$E$1828"
……
一直到
Selection.Caption = "=顺河向绘图!$AH$1"
ActiveChart.SeriesCollection(1).Select
ActiveChart.SeriesCollection(2).Name = "=顺河向绘图!$AH$2"
ActiveChart.SeriesCollection(2).Values = "=顺河向绘图!$AH$3:$AH$1828"
图表标题为
表面变形监测点B18顺河向位移-库水位-时间曲线
这个B18要用D1到AH1来循环,其他不变 展开
展开全部
Sub 宏1()
for i=4 to 34
ActiveSheet.ChartObjects("图表 1").Activate
ActiveChart.ChartArea.Copy
Cells(5, n).Select
ActiveSheet.Paste
ActiveSheet.ChartObjects("图表 50").Activate
ActiveChart.ChartTitle.Select
Selection.Caption = sheets("顺河向绘图").cells(1,i)
ActiveChart.SeriesCollection(1).Select
ActiveChart.SeriesCollection(2).Name = sheets("顺河向绘图").cells(2,i)
ActiveChart.SeriesCollection(2).Values = sheets("顺河向绘图").range(sheets("顺河向绘图").cells(3,i),sheets("顺河向绘图").cells(1828,i))
End Sub
for i=4 to 34
ActiveSheet.ChartObjects("图表 1").Activate
ActiveChart.ChartArea.Copy
Cells(5, n).Select
ActiveSheet.Paste
ActiveSheet.ChartObjects("图表 50").Activate
ActiveChart.ChartTitle.Select
Selection.Caption = sheets("顺河向绘图").cells(1,i)
ActiveChart.SeriesCollection(1).Select
ActiveChart.SeriesCollection(2).Name = sheets("顺河向绘图").cells(2,i)
ActiveChart.SeriesCollection(2).Values = sheets("顺河向绘图").range(sheets("顺河向绘图").cells(3,i),sheets("顺河向绘图").cells(1828,i))
End Sub
追问
ActiveChart.SeriesCollection(2).Name = sheets("顺河向绘图").cells(2,i)
类型不匹配(错误 13)
追答
1052974911@qq.com
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询