[大神求解]在VBA中将C列中的重复数据用红色标识出来,并弹出对话框提示,其他单元格颜色不变,谢谢!!
答案:3 悬赏:60
解决时间 2021-03-23 04:19
- 提问者网友:南佳人~
- 2021-03-22 07:18
最佳答案
- 二级知识专家网友:旧事诱惑
- 2021-03-22 08:21
Sub a()
Dim i As Long, iRow As Long
Dim strColorCell As String
iRow = Range("C60000").End(xlUp).Row
For i = 3 To iRow
If WorksheetFunction.CountIf(Range("C:C"), Range("C" & i)) > 1 Then
Range("C" & i).Interior.Color = RGB(255, 255, 0)
strColorCell = Range("C" & i).Address & Chr(10) & strColorCell
End If
Next
MsgBox strColorCell
End SubAlt+F11打开编辑窗口,插入模块,复制粘贴代码,F5运行。
代码说明:对C列进行检查,存在重复时单元格涂黄色,最后提示全部单元格地址。
Dim i As Long, iRow As Long
Dim strColorCell As String
iRow = Range("C60000").End(xlUp).Row
For i = 3 To iRow
If WorksheetFunction.CountIf(Range("C:C"), Range("C" & i)) > 1 Then
Range("C" & i).Interior.Color = RGB(255, 255, 0)
strColorCell = Range("C" & i).Address & Chr(10) & strColorCell
End If
Next
MsgBox strColorCell
End SubAlt+F11打开编辑窗口,插入模块,复制粘贴代码,F5运行。
代码说明:对C列进行检查,存在重复时单元格涂黄色,最后提示全部单元格地址。
全部回答
- 1楼网友:何以畏孤独
- 2021-03-22 10:13
Sub 标示重复()
For i = 5 To [c65536].End(3).Row
If Application.CountIf(Range("c:c"), Cells(i, 3)) > 1 Then Cells(i, 3).Interior.ColorIndex = 3
Next
End Sub
- 2楼网友:茫然不知崩溃
- 2021-03-22 08:49
Sub 标示重复()
For i = 5 To [c65536].End(3).Row
If Application.CountIf(Range("c:c"), Cells(i, 3)) > 1 Then Cells(i, 3).Interior.ColorIndex = 3
Next
End Sub
再看看别人怎么说的。
我要举报
如以上问答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯