|
自认为很漂亮、很简洁的代码:- Sub test()
- arr = [a1:b27]
- n = UBound(arr)
- Set d = CreateObject("Scripting.Dictionary")
- For i = 0 To n / 3 - 1
- d(arr(i * 3 + 2, 2) & "," & arr(i * 3 + 3, 2)) = d(arr(i * 3 + 2, 2) & "," & arr(i * 3 + 3, 2)) & "," & arr(i * 3 + 2, 1) & "," & arr(i * 3 + 3, 1)
- Next
-
- p = d.keys
- q = d.items
- ReDim brr(1 To n, 1 To 2)
- brr(1, 1) = "性别"
- brr(1, 2) = "年龄"
- For i = 0 To d.Count - 1
- k = k + 1
- t = Split(q(i), ",")
- For j = 1 To UBound(t)
- k = k + 1
- brr(k, 1) = t(j)
- brr(k, 2) = Split(p(i), ",")((k + i) Mod 2)
- Next
- Next
- [d:e] = ""
- [d1].Resize(n, 2) = brr
- End Sub
复制代码 |
评分
-
1
查看全部评分
-
|