Я не мог заставить его работать со словарями, но нашел другой способ сделать то, что мне нужно, и время вычисления очень быстро для числа строк> 60 000. Лучшее, что я мог сделать на данный момент!
Sub compareData()
Dim ListA As Range
Dim ListB As Range
Dim c As Range
'Create recordset to hold values to copy
Set rs = New Recordset
With rs
.Fields.Append "ID", adVarChar, 1000, adFldIsNullable
.Fields.Append "Sector", adVarChar, 1000, adFldIsNullable
.Fields.Append "Category", adVarChar, 1000, adFldIsNullable
.Fields.Append "Description", adVarChar, 1000, adFldIsNullable
.Fields.Append "DayNum", adVarChar, 1000, adFldIsNullable
.Fields.Append "Site", adVarChar, 1000, adFldIsNullable
.Fields.Append "Prod", adVarChar, 1000, adFldIsNullable
.Fields.Append "SU", adInteger, , adFldMayBeNull
.Fields.Append "BaseUnit", adInteger, , adFldMayBeNull
.Open
End With
'Define 2 lists to compare (ID's)
ListARange = Sheets("DATA").Cells(Rows.Count, "A").End(xlUp).Row 'Find the last row with data on column A
ListBRange = Sheets("RAW DATA").Cells(Rows.Count, "A").End(xlUp).Row 'Find the last row with data on column B
Set ListA = Sheets("DATA").Range("A2:A" & ListARange) 'Set your range only until the last row with data
Set ListB = Sheets("RAW DATA").Range("A2:A" & ListBRange)
'Check if ID already exists in the list, if not, add to recordSet
For Each c In ListB
If Application.CountIf(ListA, c) = 0 Then
rs.AddNew
rs!ID = c
rs!Sector = c.Offset(0, 1)
rs!Category = c.Offset(0, 2)
rs!Description = c.Offset(0, 3)
rs!DayNum = c.Offset(0, 4)
rs!Site = c.Offset(0, 5)
rs!Prod = c.Offset(0, 6)
rs!SU = c.Offset(0, 7)
rs!BaseUnit = c.Offset(0, 8)
rs.Update
End If
Next c