VBA - 将值存储到多维数组中

时间:2017-05-18 09:53:00

标签: arrays vba multidimensional-array

我正在尝试使用多个列重命名数组,如:

f(0,i) = ...
f(1,i) = ...
f(2,i) = ...

获得这样的东西:

->

当我尝试存储到数组中时,我的目的是:

$array = array();//Your current array
$term_variable = $array[0]->term_id; //store the term_id into the variable
print_r($term_variable); //prints the variable

代码出了什么问题?

1 个答案:

答案 0 :(得分:0)

我想创建一个包含1行和3列的数组,其中列数可能会增加。首先,我需要重新标注空数组(Dim f() As Variant),如下所示(ReDim f(0 To a, 0 To 3))。上面的代码没有用,因为我试图Redim已经标注尺寸的数组。

其次,我希望数组返回:

f(0,i) = "Bring the value from, for instance, cells A9"
f(0,i+1) = "Bring the value from, for instance, cells A16"
f(0,i+2) = "Bring the value from, for instance, cells G16"