madsnielsen
New Member
- Joined
- Oct 4, 2018
- Messages
- 12
I am doing a dictionary check, the code works with loops, but is way to slow.
I got it running with dictionary as well, however a problem appears, when the same value is already in my result matrix.
Several values in my arrSource are going to appear once or twice and I want to know EVERY time they does - not just the first time. Any help is much appreciated!
I got it running with dictionary as well, however a problem appears, when the same value is already in my result matrix.
Several values in my arrSource are going to appear once or twice and I want to know EVERY time they does - not just the first time. Any help is much appreciated!
Code:
Set dict = CreateObject("Scripting.Dictionary")
nrow_ev1 = esheet_vendor_1.Cells(Rows.count, 1).End(xlUp).Row
nrow_ec2 = esheet_customer_2.Cells(Rows.count, 1).End(xlUp).Row
arrData = Worksheets(entity_1 & " Vendor side").Range("A1:M" & nrow_ev1).Value
arrSource = Worksheets(entity_2 & " Customer side").Range("A1:M" & nrow_ec2).Value
ReDim Results(nrow_ev1, 13)
For x = 1 To UBound(arrData, 1)
key = arrData(x, 3)
If Not dict.Exists(key) Then dict.Add key, arrData(x, 6)
Next
count = 0
For x = 1 To UBound(arrSource, 1)
key = arrSource(x, 1)
If Not dict.Exists(key) Then
count = 1 + count
Results(count, 1) = arrSource(x, 1)
Results(count, 2) = arrSource(x, 2)
Results(count, 3) = arrSource(x, 3)
Results(count, 4) = arrSource(x, 4)
Results(count, 5) = arrSource(x, 5)
Results(count, 6) = arrSource(x, 6)
Results(count, 7) = arrSource(x, 7)
Results(count, 8) = arrSource(x, 8)
Results(count, 9) = arrSource(x, 9)
Results(count, 10) = arrSource(x, 10)
Results(count, 11) = arrSource(x, 11)
Results(count, 12) = arrSource(x, 12)
Results(count, 13) = arrSource(x, 13)
End If
pede = dict(key)
Next
Sheets("Ark2").Range("A3:N500000") = Results
Last edited: