|
Sub qs()
Dim arr, brr, crr, i, dic As Object
Set dic = CreateObject("scripting.dictionary")
brr = Sheet2.Range("a1").CurrentRegion.Value
For i = 4 To UBound(brr)
s = brr(i, 3) & "|" & brr(i, 6)
dic(s) = brr(i, 13)
Next
s = ""
crr = Sheet3.Range("a1").CurrentRegion.Value
For i = 2 To UBound(crr)
s = crr(i, 4) & "|" & crr(i, 5)
If Not dic.exists(s) Then
dic(s) = "" & "|" & crr(i, 8)
Else
dic(s) = dic(s) & "|" & crr(i, 8)
End If
Next
On Error Resume Next
arr = Sheet1.Range("a2:k" & Sheet1.Cells(Rows.Count, 2).End(xlUp).Row)
ReDim drr(1 To UBound(arr), 1 To UBound(arr, 2))
For Each k In dic.keys
m = 0
For i = 1 To UBound(arr)
t = arr(i, 2) & "|" & arr(i, 3)
If t = k Then
arr(i, 10) = Split(dic(t), "|")(0)
arr(i, 11) = Split(dic(t), "|")(1)
m = m + 1
GoTo 100
End If
Next
100
If m = 0 Then
rw = rw + 1
drr(rw, 2) = Split(k, "|")(0)
drr(rw, 3) = "'" & Split(k, "|")(1)
drr(rw, 10) = Split(dic(k), "|")(0)
drr(rw, 11) = Split(dic(k), "|")(1)
drr(rw, 9) = "没有名字"
End If
Next
With Sheet1
.Range("j2").Resize(UBound(arr), 1) = Application.Index(arr, 0, 10)
.Range("k2").Resize(UBound(arr), 1) = Application.Index(arr, 0, 11)
.Range("a" & UBound(arr) + 2).Resize(10000, UBound(arr, 2)) = ""
.Range("a" & UBound(arr) + 2).Resize(rw, UBound(arr, 2)) = drr
End With
MsgBox "完成!"
End Sub
|
|