|
楼主 |
发表于 2022-7-12 10:17
|
显示全部楼层
没有系统的整理,就是用到啥录制宏改改。数据处理的代码,我整理一下- Sub Main()
- Dim xAr, yAr
- With ActiveSheet
- n = .Range("C2").Value
- xAr = GetxValues(50, 80, 40, n)
- .Range("T2").Resize(, UBound(xAr)).Value = xAr
- r = 2
- For c = 4 To 7
- ar = .Cells(6, c).Resize(n).Value
- yAr = GetyValues(ar)
- yAr2 = GetYValues2(yAr)
- '---输出位置
- r = r + 2
- .Range("T" & r).Resize(, UBound(yAr)).Value = yAr
- .Range("T" & r + 1).Resize(, UBound(yAr2)).Value = yAr2
- Next
- End With
- End Sub
- Rem 系列数据展开为4个一组,重复两次空两个
- Rem ar对应一列数据的值
- Function GetyValues(ar)
- Dim yAr, u%, i%, j%
- u = UBound(ar)
- ReDim yAr(1 To u * 4)
- For i = 1 To u
- j = i * 4 - 3
- yAr(j) = ar(i, 1)
- yAr(j + 1) = yAr(j)
- Next
- GetyValues = yAr
- End Function
- Rem 间隔数据辅助系列
- Function GetYValues2(ar)
- Dim br, u%, i%, k
- u = UBound(ar)
- ReDim br(1 To u)
- For i = 1 To u - 1
- k = ar(i)
- If Len(k) = 0 Then
- br(i) = ar(i + (-1) ^ (i Mod 2))
- End If
- Next
- GetYValues2 = br
- End Function
- Rem 计算出X轴的坐标数据
- Rem StartX,W0,W1,N0对应X轴其实刻度,柱形的宽度,间隔连接四边形刻度,数据的数量
- Function GetxValues(StartX, W0, W1, N0)
- Dim xAr, i%, j%, k
- ReDim xAr(1 To N0 * 4)
- '---X轴坐标两两一组
- xAr(1) = StartX
- For i = 2 To UBound(xAr) - 1 Step 2
- j = j Mod 2 + 1
- If j = 2 Then
- xAr(i) = xAr(i - 1) + W1
- Else
- xAr(i) = xAr(i - 1) + W0
- End If
- xAr(i + 1) = xAr(i)
- Next
- GetxValues = xAr
- End Function
复制代码
图表的代码就不值得整理了,太乱。其实就是录制完改改 |
|