|
楼主 |
发表于 2017-8-25 12:43
|
显示全部楼层
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
老师你好:我按照你的方法,插入模块,将代码全部打进去,执行有错误,停顿在图片下面位置。
Sub lqxs()
Dim arr, ks, js(3), shnm$, nm2$, dz2$, cht As Chart
Dim dz$, dz3$, yy$, nm, m&, i&, j&
Application.ScreenUpdating = False
shnm = Sheet1.Name
nm = Array("图表 1", "图表 3", "图表 4", "图表 5")
ks = Array(9, 37, 67, 95)
For j = 0 To UBound(nm)
arr = Sheet1.Cells(ks(j), 6).CurrentRegion
For i = 2 To UBound(arr)
If arr(i, 1) = "" Then js(j) = i + ks(j) - 2: Exit For
Next
dz = "f" & ks(j) & ":h" & js(j)
ActiveSheet.ChartObjects(nm(j)).Activate
Set cht = ActiveChart
With cht
.SetSourceData Source:=Sheet1.Range(dz), PlotBy:=xlColumns
dz1 = "g" & ks(j) + 1 & ":g" & js(j)
.SeriesCollection(1).Values = "=" & shnm & "'!" & dz1
dz2 = "h" & ks(j) + 1 & ":h" & js(j)
.SeriesCollection(2).Values = "=" & shnm & "'!" & dz2
End With
Next
[a1].Select
Application.ScreenUpdating = True
End Sub
在Sheet4 插入:
Private Sub Worksheet_Activate()
Call lqxs
End Sub
以上我想通过一个按钮来生成,麻烦老师再帮忙看下。
|
|