|
Option Explicit
Sub TEST6()
Dim ar, br, i&, j&, dic As Object
Application.ScreenUpdating = False
Set dic = CreateObject("Scripting.Dictionary")
ar = Worksheets(2).[E2].CurrentRegion.Value
For i = 2 To UBound(ar)
dic(ar(i, 1)) = dic(ar(i, 1)) & " " & ar(i, 2)
Next i
With Worksheets(1)
ar = .[B2].CurrentRegion.Value
For i = 2 To UBound(ar)
If Len(ar(i, 3)) = False Then
If dic.exists(ar(i, 1)) Then
br = Split(dic(ar(i, 1)))
For j = 1 To UBound(br)
If (ar(i, 2) - br(j)) <= ar(i, 2) * 0.01 Then
ar(i, 3) = br(j): Exit For
End If
Next j
End If
End If
Next i
.[K2].Resize(UBound(ar), UBound(ar, 2)) = ar
.Activate
End With
Set dic = Nothing
Application.ScreenUpdating = True
Beep
End Sub
|
|