在excel列中查找重复单元格
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了在excel列中查找重复单元格相关的知识,希望对你有一定的参考价值。
Sub FindDups () ' ' NOTE: You must select the first cell in the column and ' make sure that the column is sorted before running this macro ' ScreenUpdating = False FirstItem = ActiveCell.Value SecondItem = ActiveCell.Offset(1, 0).Value Offsetcount = 1 Do While ActiveCell <> "" If FirstItem = SecondItem Then ' Uncomment next line to highlight both repeating lines ' ActiveCell.Offset(Offsetcount - 1,0).Interior.Color = RGB(255,0,0) ActiveCell.Offset(Offsetcount,0).Interior.Color = RGB(255,0,0) Offsetcount = Offsetcount + 1 SecondItem = ActiveCell.Offset(Offsetcount, 0).Value Else ActiveCell.Offset(Offsetcount, 0).Select FirstItem = ActiveCell.Value SecondItem = ActiveCell.Offset(1,0).Value Offsetcount = 1 End If Loop ScreenUpdating = True End Sub
以上是关于在excel列中查找重复单元格的主要内容,如果未能解决你的问题,请参考以下文章
在EXCEL中 如何用VBA查找某特定单元格并返回该单元格的行和列值?
在选定 Excel 列的单元格中查找并突出显示重复的单元格和文本字符串