|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
- Sub 重复数据标黄提示重复的行号()
- Dim i%, j%, s, brr, ss As String, x
- Dim dic As Object, key, keys, items
- Set dic = CreateObject("scripting.dictionary")
- Sheet2.Activate
-
- Cells.Interior.Color = vbWhite
- Range("e2:e5001").ClearContents
- x = 2
- For i = 2 To Cells(Rows.Count, "C").End(xlUp).Row
- key = Cells(i, 4)
- dic(key) = dic(key) & "," & i
- Next
- For i = 2 To Cells(Rows.Count, "C").End(xlUp).Row
- key = Cells(i, 4)
- brr = Split(dic(key), ",")
- s = ""
- For j = 1 To UBound(brr)
- If brr(j) <> i Then
- s = s & "," & brr(j)
- If UBound(brr) <= 2 Then
- ss = "与第" & Mid(s, 2) - 1 & "行重复"
- Else
- ss = ss & "与第" & Mid(s, x) - 1 & "行重复"
- x = x + 2
- End If
- Cells(i, 5).Interior.Color = vbYellow
- Cells(i, 3).Interior.Color = vbYellow
- Cells(i, 5) = ss
- End If
- Next
- ss = ""
- x = 2
- Next
- End Sub
复制代码 |
|