Arrays 基于另一个数组的值在数组中插入元素

Arrays 基于另一个数组的值在数组中插入元素,arrays,vba,Arrays,Vba,我有两个非常大的文件,需要在它们之间传递信息。目前,我正在遍历两个文件中较大的文件,并使用数组存储较小的文件。然后,我用数组中的元素更新较大文件中的字段,这是可行的,但在文件中循环需要很长时间。我要做的是将两个文件放在不同的数组中,并在数组中循环,将元素从一个数组插入到另一个数组中,就像我处理文件一样 我能找到我要找的东西我很难插入名字 'loop through first Array For X = UBound(arrOne) To 2 Step -1 'loop through

我有两个非常大的文件,需要在它们之间传递信息。目前,我正在遍历两个文件中较大的文件,并使用数组存储较小的文件。然后,我用数组中的元素更新较大文件中的字段,这是可行的,但在文件中循环需要很长时间。我要做的是将两个文件放在不同的数组中,并在数组中循环,将元素从一个数组插入到另一个数组中,就像我处理文件一样

我能找到我要找的东西我很难插入名字

'loop through first Array
For X = UBound(arrOne) To 2 Step -1

    'loop through second array
    For A = UBound(arrTwo) To LBound(arrTwo) Step -1

        'check if the primary key in the first array is in the second array
        If arrOne(X, 1) = arrTwo(A, 1) Then

            'if the keys match find the secondary key 
            'AND make sure the name field is empty
            If arrOne(X, 69) = arrTwo(A, 2) And arrOne(X, 83) = "" Then

               'if keys match and there is no name - insert the name 
               'from arrTwo into arrOne
                arrOne.Add(X, 69) arrTwo(A, 2)

            End If

        Else

            'Insert Empty Values into Insurance rows

        End If
    Next A
Next A

数组没有
Add
方法。如果只想将一个数组中的值分配给另一个数组中的插槽:

 arrOne(X, 69) = arrTwo(A, 2)
因为您已经检查过这两个值相等,所以不清楚这条线的用途是什么


如果只需要一个匹配项,那么在该行之后添加
Exit For
将加快处理速度。

文件的格式是什么?CSV?简单的文本行?