我正在尝试使用Excel中的VBA将大型数组减少为多个较小的数组(这些数组可以是任意长度)。例如,我有这个数组:
表单1
A
C
d
电子
˚F
表格2
取值
取值
瓦特
电子
表格3
$
ħ
我想使用VBA分别获取array1,array2,array3(可以有任意数量的数组)。我已经编写了一个函数来获取每个数组的长度,但不知道如何拆分它们。任何帮助将不胜感激!
编辑:以下是我目前使用的代码中提出的一般概念:
Sub myFunction()
Dim collection1 As New Collection
Dim array2, array3 As Variant
Dim i, k As Long
Set ws1 = Worksheets("Sheet1")
i = 1
k = 1
'numList is a global array that has some number of values
'each value is the length of each form (see above if confused)
lastRow = ws1.Cells(Rows.Count, "A").End(xlUp).Row
array2 = Range("A1:A" & lastRow).Value
'entirety of data spreadsheet grabbed
array3 = Range("A1:O" & lastRow).Value
Do While i < Application.WorksheetFunction.Count(numList)
Value1 = numList(i, 1)
'I don't know how to use redim
'I want to take array2(k,1):array2(value1,15) (or Range("A" & k : "O" & (k + Value1 - 1))
'And make this an entry in my collection
'collection1.Add Redim
k = k + Value1
i = i + 1
Loop
End Sub