|
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
要显示在旁边可用如下:
- Sub 找重复值()
- Dim r%, i%, arr, mkey, mitems
- Set d = CreateObject("scripting.dictionary")
- r = Cells(Rows.Count, 1).End(xlUp).Row
- arr = Range("a1:c" & r)
- For i = 2 To UBound(arr)
- If Not d.Exists(arr(i, 1)) Then
- d(arr(i, 1)) = i
- Else
- d(arr(i, 1)) = d(arr(i, 1)) & "," & i
- End If
- Next
- For Each mkey In d.keys
- mitems = Split(d(mkey), ",")
- r = UBound(mitems): i = mitems(0)
- If r > 0 Then
- arr(i, 2) = r + 1: arr(i, 3) = d(mkey)
- End If
- Next
- Range("a1").Resize(60000, UBound(arr, 2)).Clear
- Range("a1").Resize(UBound(arr), UBound(arr, 2)) = arr
- Erase arr, mitems: Set d = Nothing
- End Sub
复制代码 |
|