Welcome!
I have problem with preparing function or part of the code which provides operation on data in structure below (data in this format is already stored in Array):
ID Flag Company
33 AB 67345
33 ABC 53245
33 C 67345
33 AB 25897
33 A 89217
33 BC 81237
33 B 89217
33 C 89217
The purpose of the exercise is to obtain new array with combined records based on the key ID + Company. So basically output should be:
33 ABC 67345
33 ABC 53245
33 AB 25897
33 ABC 89217
33 BC 81237
I have tried several solution but still not getting final result. I used loops or comparing methods.
Can anyone provide vital solution? Performance is not a key at this point, the most important is solution that will solve this problem.
I have tried solution with moving values from Array to another but still I get duplicated rows for example:
33 ABC 89217
33 AB 89217
33 C 89217
Example of the code:
For i = 1 To UBound(Array1)
If Array1(i, 13) <> "Matched" Then
strTestCase = Array1(i, 1) & Array1(i, 9)
strLegalEntityType = EntityFlag(Array1(i, 5))
For j = 1 To UBound(Array1)
If Array1(j, 1) & Array1(j, 9) = strTestCase Then
Array1(i, 13) = "Matched"
End If
If EntityFlag(Array1(i, 5)) = EntityFlag(Array1(j, 5)) Then
arrTemporary1(i, 5) = EntityFlag(Array1(j, 5)) & strLegalEntityType
arrTemporary1(i, 5) = funcRemoveDuplicates(arrTemporary1(i, 5))
arrTemporary1(i, 1) = Array1(i, 1)
arrTemporary1(i, 2) = Array1(i, 2)
arrTemporary1(i, 3) = Array1(i, 3)
arrTemporary1(i, 4) = Array1(i, 4)
arrTemporary1(i, 6) = Array1(i, 6)
arrTemporary1(i, 7) = Array1(i, 7)
arrTemporary1(i, 8) = Array1(i, 8)
arrTemporary1(i, 9) = Array1(i, 9)
arrTemporary1(i, 10) = Array1(i, 10)
arrTemporary1(i, 11) = Array1(i, 11)
arrTemporary1(i, 12) = Array1(i, 12)
a = a + 1
End If
Next j
End If
Next i
