|
- Sub test()
- Dim d As New Dictionary
- With Worksheets("表一")
- r = .Cells(.Rows.Count, 1).End(xlUp).Row
- .Range("c1:c" & r).ClearContents
- arr = .Range("a2:c" & r)
- End With
-
- With Worksheets("表二")
- r = .Cells(.Rows.Count, 1).End(xlUp).Row
- .Range("c1:c" & r).ClearContents
- brr = .Range("a2:c" & r)
- End With
-
- For i = 1 To UBound(brr)
- xm = brr(i, 1) & "+" & brr(i, 2)
- d(xm) = i
- Next
-
- For i = 1 To UBound(arr)
- xm = arr(i, 1) & "+" & arr(i, 2)
- If d.Exists(xm) Then
- arr(i, 3) = "都有"
- brr(d(xm), 3) = "都有"
- Else
- arr(i, 3) = "表二没有"
- End If
- Next
-
- For i = 1 To UBound(brr)
- If Len(brr(i, 3)) = 0 Then
- brr(i, 3) = "表一没有"
- End If
- Next
- With Worksheets("表一")
- .Range("c2").Resize(UBound(arr), 1) = Application.Index(arr, 0, 3)
- End With
-
- With Worksheets("表二")
- .Range("c2").Resize(UBound(brr), 1) = Application.Index(brr, 0, 3)
- End With
- End Sub
复制代码 |
|