|
为什么非要用For Each rng In d.items ?
这样行了吧?
- Sub test()
- Set d = CreateObject("scripting.dictionary")
- Application.ScreenUpdating = False
- Arr = [c2].CurrentRegion
- [c2].CurrentRegion.ClearFormats
- For j = 1 To UBound(Arr)
- If d.exists(Arr(j, 1)) Then
- Set d(Arr(j, 1)) = Union(Cells(j + 1, 3), d(Arr(j, 1)))
- Else
- Set d(Arr(j, 1)) = Cells(j + 1, 3)
- End If
- Next
- For Each rng In d.items
- If rng.Count > 1 Then
- rng.Interior.Color = 255
- a = a + 1
- Cells(a, "F") = "重复了" & rng.Count & "次,单元格是:(" & rng.Address(0, 0) & ")"
- p = p & "重复了" & rng.Count & "次,单元格是:(" & rng.Address(0, 0) & ")" & Chr(10)
- ' MsgBox "重复了" & rng.Count & "次,单元格是:(" & rng.Address(0, 0) & ")"
- End If
- Next
- If p <> "" Then MsgBox p
- Application.ScreenUpdating = True
- End Sub
复制代码 |
|