|
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
test 是3个要求一起实现的代码。
然后test1、test2、test3,是各个要求各自实现的代码。
- Sub test()
- m = [a1].End(4).Row
- ar = [a1].Resize(m + 4)
-
- ReDim br(1 To m, 1 To 3)
- For i = 1 To m Step 5
- t = ar(i, 1): r = i
- For i2 = i + 1 To i + 4
- If ar(i2, 1) > t Then t = ar(i2, 1): r = i2
- Next
- br(r, 1) = t
- k = k + 1: br(k, 2) = t
- s = s + t
- Next
- br(1, 3) = s
- [b1].Resize(m, 3) = br
- End Sub
- Sub test1()
- m = [a1].End(4).Row
- ar = [a1].Resize(m + 4)
-
- ReDim br(1 To m, 1 To 1)
- For i = 1 To m Step 5
- t = ar(i, 1): r = i
- For i2 = i + 1 To i + 4
- If ar(i2, 1) > t Then t = ar(i2, 1): r = i2
- Next
- br(r, 1) = t
- Next
- [b1].Resize(m) = br
- End Sub
- Sub test2()
- m = [a1].End(4).Row
- ar = [a1].Resize(m + 4)
-
- ReDim br(1 To m, 1 To 1)
- For i = 1 To m Step 5
- t = ar(i, 1)
- For i2 = i + 1 To i + 4
- If ar(i2, 1) > t Then t = ar(i2, 1)
- Next
- k = k + 1
- br(k, 1) = t
- Next
- [c1].Resize(k) = br
- End Sub
- Sub test3()
- m = [a1].End(4).Row
- ar = [a1].Resize(m + 4)
-
- For i = 1 To m Step 5
- t = ar(i, 1)
- For i2 = i + 1 To i + 4
- If ar(i2, 1) > t Then t = ar(i2, 1)
- Next
- s = s + t
- Next
- [d1] = s
- End Sub
复制代码 |
评分
-
1
查看全部评分
-
|