|
本帖最后由 香川群子 于 2014-2-12 13:55 编辑
补充,嵌套数组中,每一个子数组的大小也可以不同:- Sub test2()
- Dim arr(1 To 200)
-
- Dim x(2)
- Dim y1(1 To 1, 1 To 2)
- Dim y2(1 To 2, 1 To 3)
- Dim y3(1 To 3, 1 To 4)
- x(0) = y1
- x(1) = y2
- x(2) = y3
-
- For i = 0 To 200 - 1
- arr(i + 1) = x(i Mod 3)
- Next
-
- For i = 1 To UBound(arr)
- For j = 1 To UBound(arr(i), 1)
- For k = 1 To UBound(arr(i), 2)
- cnt = cnt + 1
- arr(i)(j, k) = i & "_" & j & "_" & k
- Next
- Next
- Next
- MsgBox cnt
-
- [a1].CurrentRegion = ""
- cnt = 1
- For i = 1 To 200
- Cells(cnt, 1).Resize(UBound(arr(i), 1), UBound(arr(i), 2)) = arr(i)
- cnt = cnt + UBound(arr(i), 1)
- Next
-
- End Sub
复制代码 |
|