Question Regarding Dictionary

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!

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:

Excel Facts

Select all contiguous cells
Pressing Ctrl+* (asterisk) will select the "current region" - all contiguous cells in all directions.
Are you trying to get a list of unique values and then count how many times they occur?
 
Upvote 0
Sorry if I was being imprecise.






I have tolists of numbers.
Column 3 and column 1 in the lists have a lot of the same numbers, with fewexceptions.
I want a list of all the exceptions. My code now provides me with this.



However, I alsowant the rest of the columns in the row where there is an exception, becauseevery time there is an exception the row has changed.
The problem is that the code only provide me with the first exception; Does Itmake sense?

 
Upvote 0
By 'exceptions' do you mean numbers not in the first list but in the second or vice versa?
 
Upvote 0

Forum statistics

Threads
1,223,903
Messages
6,175,284
Members
452,630
Latest member
OdubiYouth

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top