|
- Sub 按钮1_Click()
- Set d = CreateObject("scripting.dictionary")
- Dim rng As Range
- Application.ScreenUpdating = False
- arr = [a1].CurrentRegion
- str1 = [a1]
- For j = 1 To UBound(arr)
- If Not d.exists(arr(j, 1)) Then
- Set d(arr(j, 1)) = Cells(j, 2)
- Else
- Set d(arr(j, 1)) = Union(d(arr(j, 1)), Cells(j, 2))
- End If
- Next j
- For j = 0 To d.Count - 1
-
- For i = j + 1 To d.Count - 1
- Set r = Nothing
- For Each rng In d.items()(j)
- For Each rn In d.items()(i)
- If rng.Value = rn.Value Then
- If r Is Nothing Then
- Set r = Union(rng, rn)
- Else
- Set r = Union(r, rng, rn)
- End If
- End If
- Next rn
- Next rng
- If Not r Is Nothing Then
- If r.Cells.Count Mod 4 = 0 Then
- r.Interior.ColorIndex = 6
- End If
- End If
- Next i
- Next j
- Application.ScreenUpdating = True
- End Sub
复制代码 |
|