|
楼主 |
发表于 2023-6-6 14:51
|
显示全部楼层
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
还有个问题
下面的代码如何优化呀 分别判断A列 B列是否存在重复值,重复值填充蓝色 代码跑几千行数据时候太卡了
Dim cell As Range '“身份证号A列”范围内的重复值并将它们标记为蓝色
For Each cell In Range("A2:A" & Cells(Rows.Count, 2).End(xlUp).Row)
If WorksheetFunction.CountIf(cell.Parent.Columns(1), cell.Value & "*") > 1 Then
cell.Interior.color = RGB(0, 0, 255)
End If
Next cell
Dim shenfenzheng As Range '“身份证号A列”空白行背景色
For Each shenfenzheng In Range("A2:A" & Cells(Rows.Count, "A").End(xlUp).Row)
If Len(shenfenzheng.Value) = 0 Then
shenfenzheng.Interior.ColorIndex = xlNone
End If
Next shenfenzheng
For Each cell In Range("B2:B" & Cells(Rows.Count, 2).End(xlUp).Row) '”学籍号B列”范围内的重复值并将它们标记为蓝
If WorksheetFunction.CountIf(cell.Parent.Columns(2), cell.Value & "*") > 1 Then
cell.Interior.color = RGB(0, 0, 255)
End If
Next cell
Dim xuejihao As Range '清楚B列学籍号空白行背景色
For Each xuejihao In Range("B2:B" & Cells(Rows.Count, "B").End(xlUp).Row)
If Len(xuejihao.Value) = 0 Then
xuejihao.Interior.ColorIndex = xlNone
End If
Next xuejihao
|
|