在VBA

时间:2019-06-03 07:51:57

标签: arrays vba

我想将数组名作为字符串传递。

 Dim i as Integer
 Dim arName as String
 Dim ar1(10) as Integer 'array of 10 elements
 Dim ar2(10) as Integer
 Dim ar3(10) as Integer

 for i = 1 to 3
     arName ="ar" & i
     arName(1)=34 ' I want 34 in every 1st element of all three arrays 
 Next i
 End sub

我这样做是作为数组练习。 我的问题是如何将数组名称作为字符串传递

1 个答案:

答案 0 :(得分:1)

只需创建一个多维数组

Dim i As Integer
Dim arr(1 To 3, 1 To 10) As Integer
For i = 1 To 3
    arr(i, 1) = 34
Next