在VBA中,我想声明一组数组。说X01,X02,..,X99 每个都有不同的尺寸
我尝试了Dim X(1到99)。但是,以后很难为每个尺寸设置尺寸。
在这种情况下,有没有效率的方法来声明数组? 示例:
X01: size (5,6)
X02: size (2,3)
X03: size (1,9)
etc
答案 0 :(得分:0)
也许...
Option Explicit
Public Sub ArraysOfArrays()
' Option #1 ... individual, explicit definitions
Dim X01(5, 6)
Dim X02(6, 3)
' etc
' Option 2 ... a three dimension array
Dim Y(99, 10, 10)
Y(0, 0, 0) = "A"
Y(1, 5, 6) = "B"
' etc
' Option 3 ... an array of different arrays
Dim Tmp
Dim Z(99)
ReDim Tmp(5, 6): Z(0) = Tmp
ReDim Tmp(6, 3): Z(1) = Tmp
' etc
' Option 4
' ... create a table with three keys in some form of database
' Option 5
' ... use a worksheet, a dictionary or one of the myriad of other options :)
End Sub