|
发表于 2012-10-10 16:37
|
显示全部楼层
本楼为最佳答案
- Sub 比较2()
- Dim dic1 As Object, dic2 As Object
- Dim iRow As Long
- Dim i As Long, arr, srg As String, str1 As String, str2 As String
- iRow = [f1].End(xlDown).Row
- arr = Range("f1:g" & iRow).Value
- Set dic1 = CreateObject("scripting.dictionary")
- Set dic2 = CreateObject("scripting.dictionary")
-
- For i = 2 To iRow
- If Not dic1.exists(arr(i, 1)) And arr(i, 1) <> 0 Then
- dic1.Add arr(i, 1), i
- End If
- If Not dic2.exists(arr(i, 2)) And arr(i, 2) <> 0 Then
- dic2.Add arr(i, 2), i
- End If
- Next
- arr = dic1.keys
- For i = 0 To UBound(arr)
- If dic1.exists(arr(i)) And dic2.exists(arr(i)) Then
- str1 = Replace(Cells(Val(dic1(arr(i))), "f").Address, "$", "") & ","
- str2 = Replace(Cells(Val(dic2(arr(i))), "f").Address, "$", "") & ","
- If Len(srg & str1 & str2) > 249 Then
- Range(Left(srg, Len(srg) - 1)).EntireRow.Interior.ColorIndex = 35
- srg = str1 & str2
- Else
- srg = srg & str1 & str2
- End If
- End If
- Next
- End Sub
复制代码 |
|