|
- Sub kkk()
- Dim d As Object, arr As Variant, i&, j&, a As Variant, theStr$, theStr1$, theStr2$
- Set d = CreateObject("Scripting.Dictionary")
- With Sheet1
- .Cells.Interior.ColorIndex = xlNone
- .Columns(5).Clear
- MsgBox "单击以继续……", vbInformation, "提示"
- arr = .Cells(1).CurrentRegion
- For i = 2 To UBound(arr)
- theStr = arr(i, 2)
- If theStr <> "" Then
- a = Split(theStr, "/")
- If UBound(a) = 0 Then
- d(a(0)) = i
- End If
- theStr = theStr & arr(i, 4)
- If Not d.Exists(theStr) Then
- d(theStr) = i
- theStr = ""
- For j = UBound(a) To 0 Step -1
- If theStr = "" Then
- theStr = a(j)
- Else
- theStr = theStr & "/" & a(j)
- theStr = theStr & arr(i, 4)
- If Not d.Exists(theStr) Then
- d(theStr) = i
-
- Else
- .Cells(d(theStr), 5) = "相同"
- .Range(.Cells(d(theStr), 4), .Cells(d(theStr), 5)).Interior.ColorIndex = 6
- .Cells(d(theStr), 2).Interior.ColorIndex = 6
- .Cells(i, 5) = "相同"
- .Range(.Cells(i, 4), .Cells(i, 5)).Interior.ColorIndex = 6
- .Cells(i, 2).Interior.ColorIndex = 6
- End If
- End If
- Next j
- Else
- .Cells(d(theStr), 5) = "相同"
- .Range(.Cells(d(theStr), 4), .Cells(d(theStr), 5)).Interior.ColorIndex = 6
- .Cells(d(theStr), 2).Interior.ColorIndex = 6
- .Cells(i, 5) = "相同"
- .Range(.Cells(i, 4), .Cells(i, 5)).Interior.ColorIndex = 6
- .Cells(i, 2).Interior.ColorIndex = 6
- End If
- End If
- Next i
- End With
- Set d = Nothing
- End Sub
复制代码 |
|