Hello Friends!
One of our Moderators - Fluff - is providing Dictinaries which speeds up everything beyond expectations.
Can You make for me a macro that will compare colums A,E,G and remove duplicates in this fashion?
ex.
IF A5, E5, G5 has the same values as A54321, E54321, G54321 and A99, E99, G99 Then leave only one instance of that record. (all in one sheet!)
A5 = 10, E5 = 100, G5 = PP1 / A54321 = 10, E54321 = 100, G54321 = PP1 / 99 = 10, E99 = 100, G99 = PP1
(fashion)
I have working code made by myself (myself = slow) but I was wondering if it can be speedup by dictionaries.
Usually Im importing 28-31 text files to seperate sheets (for every day of month) and work on them. Each has between 500K-1.5M records.
Best regards
W.
One of our Moderators - Fluff - is providing Dictinaries which speeds up everything beyond expectations.
Can You make for me a macro that will compare colums A,E,G and remove duplicates in this fashion?
ex.
IF A5, E5, G5 has the same values as A54321, E54321, G54321 and A99, E99, G99 Then leave only one instance of that record. (all in one sheet!)
A5 = 10, E5 = 100, G5 = PP1 / A54321 = 10, E54321 = 100, G54321 = PP1 / 99 = 10, E99 = 100, G99 = PP1
(fashion)
Code:
Dim Cl As Range
Dim v1 As String
Dim Ws1 As Worksheet
Dim Ws2 As Worksheet
Set Ws1 = Sheets(1)
Set Ws2 = Sheets(2)
With CreateObject("Scripting.dictionary")
For Each Cl In Ws2.Range("A2", Ws2.Range("A" & Rows.count).End(xlUp))
v1 = Cl.Value & Cl.Offset(, 3).Value
If Not .Exists(v1) Then .Add v1, Cl.Offset(, 5).Offset(, 2).Value
Next Cl
For Each Cl In Ws1.Range("A2", Ws1.Range("A" & Rows.count).End(xlUp))
v1 = Cl.Value & Cl.Offset(, 4).Value
If .Exists(v1) Then Cl.Offset(, 10).Offset(, 3).Value = .Item(v1)
Next Cl
End With
I have working code made by myself (myself = slow) but I was wondering if it can be speedup by dictionaries.
Usually Im importing 28-31 text files to seperate sheets (for every day of month) and work on them. Each has between 500K-1.5M records.
Best regards
W.
Last edited: