Naming an array using a variable

后端 未结 2 1955
温柔的废话
温柔的废话 2021-01-27 07:45

Is it possible to name an array variable using a different variable? For example, if I define variable \"i\" as an integer with a value equal to the number of columns I\'ve use

2条回答
  •  礼貌的吻别
    2021-01-27 08:08

    You can create an array of arrays (though your question is a little unclear..)

    Sub MyArrays()
    
    Dim arrays()
    Dim arr
    Dim i, j
    
        i = 5 'e.g.
        ReDim arrays(1 To i)
    
        For j = 1 To i
            arr = Array()
            ReDim arr(1 To j)
            arrays(j) = arr
        Next j
        'reference an array by its position in "arrays"
        Debug.Print UBound(arrays(3))
    
    End Sub
    

提交回复
热议问题