MyHanhCB
New Member
- Joined
- Feb 20, 2023
- Messages
- 30
- Office Version
- 2016
- Platform
- Windows
Hello everyone in the Mrexcel forum.
I am a foreigner, specifically Vietnamese, so my English may not be fluent. Anything offensive to me sorry.
I have an array A containing 15000 values, and an array B containing 10000 values. I want to find if each value in array A is in array B or not. If not, save that value in array C (array C is the value I'm looking for).
I use this 1 piece of code in my project. But it works quite slow.
Can you guys help me with an alternative code that can work faster?. Thank you very much.
I am a foreigner, specifically Vietnamese, so my English may not be fluent. Anything offensive to me sorry.
I have an array A containing 15000 values, and an array B containing 10000 values. I want to find if each value in array A is in array B or not. If not, save that value in array C (array C is the value I'm looking for).
I use this 1 piece of code in my project. But it works quite slow.
Can you guys help me with an alternative code that can work faster?. Thank you very much.
VBA Code:
Dim found As Boolean
found = False
o = 0
27 For i = LBound(rn1, 1) To UBound(rn1, 1)
traRn1 = rn1(i, 1) & "#" & rn1(i, 2) & "#" & rn1(i, 3)
For l = LBound(rn2, 1) To UBound(rn2, 1)
29 traRn2 = rn2(l, 1) & "#" & rn2(l, 2) & "#" & rn2(l, 3)
31 If traRn1 <> "##" Or traRn2 <> "##" Then
If traRn1 = traRn2 Then
found = True
Exit For
End If
End If
Next l
33 If traRn1 <> "##" Or traRn2 <> "##" Then
If Not found Then
o = o + 1
ReDim Preserve so(1 To o)
so(o) = rn1(i, 1) & "_" & rn1(i, 2)
End If
End If
found = False
Next i