I align one set of data to another looping though cells. Essentially if IDs match and the next condition is satisfied, copy and paste the cell from one data set to the other in a new column.
Looping though cells takes forever. I tried using arrays. I get the error
subscript out of range
in If array2(i, 2) = array1(j, 7) Then.
Dim array1 As Variant
Dim array2 As Variant
Dim i, j As Integer
array1 = Range("A2:k100000").Value
array2 = Range("M2:Q834").Value
For i = 1 To UBound(array2, 2)
For j = 1 To UBound(array1, 2)
If array2(i, 2) = array1(j, 7) Then '//get a subscript out of range error here
If array2(i, 3) <= array1(j, 10) And array2(i, 3) >= array1(j, 9) Then
If IsEmpty(array1(j, 11)) Then array1(j, 11) = array2(i, 1)
Else: array1(j, 11) = array1(j, 11).Concat(array2(i, 1))
End If
End If
Next j
Next i
As Longinstead ofAs Integerdue to the limitations onAs Integer