Question : Combining Arrays in VBA

I have 2 Arrays (Array1(89,2) & Array2(83,3)) and I would like to merge these into a single array that is 89x4.

Array1:
* Column1 - Unique ID
* Column2 - Counter

Array2:
* Column1 - Unique ID
* Column2 - Laptop Counter
* Column3 - Desktop Counter

Desired Array:
* Column1 - Unique ID
* Column2 - Counter
* Column3 - Laptop Counter
* Column4 - Desktop Counter

How can I use these arrays to create this information?

Answer : Combining Arrays in VBA

I see ... so there will be some holes ... OK, try this:
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
dim NewArray as String(89,4)
dim i as integer, j as integer
 
for i = 1 to 89
  newArray(i,1) = Array1(i,1)
  newArray(i,2) = Array1(i,2)
  for j = 1 to 83
    if Array2(j,1) = Array1(i,1) then
        newArray(i,3) = Array2(j,2)
        newArray(i,4) = Array2(j,3)
        exit for 'This will break out of the "for j" loop but not the "for i" loop
    end if
  next j
next i
Random Solutions  
 
programming4us programming4us