|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
定义名称有点麻烦,用代码做的。开表,启用宏。
- Option Explicit
- Sub DynChart()
- Dim dbl5Loop#(), dbl10Loop#(), strAxis$()
- Dim rng5Loop As Range, rngPoint As Range, A%, intSerCnt%, bytStageNum As Byte
- intSerCnt = [A100].End(xlUp).Row - 2
- bytStageNum = [H16].Value
- Set rng5Loop = [A3].Resize(intSerCnt).Offset(0, bytStageNum * 2 - 1)
- For Each rngPoint In rng5Loop
- If rngPoint.Value <> Empty Then
- ReDim Preserve dbl5Loop(A), dbl10Loop(A), strAxis(A)
- dbl5Loop(A) = rngPoint.Value
- dbl10Loop(A) = rngPoint.Offset(0, 1).Value
- strAxis(A) = Range("A" & rngPoint.Row).Value
- A = A + 1
- End If
- Next
- With Me.ChartObjects("图表 1").Chart
- .SeriesCollection(1).Values = dbl5Loop
- .SeriesCollection(2).Values = dbl10Loop
- .SeriesCollection(1).XValues = strAxis
- End With
- End Sub
复制代码 |
评分
-
1
查看全部评分
-
|