XL:Sample Macro to Find Duplicate Entries in a RowLast reviewed: September 2, 1997Article ID: Q142591 |
The information in this article applies to:
SUMMARYThe Visual Basic for Applications example in this article finds duplicate cell entries within a column and changes the color of the cell containing the duplicate entry to red.
MORE INFORMATIONIn order for the macro to function correctly, you must make sure the following conditions are met:
Sample Visual Basic Code
Sub FindDups ()
ScreenUpdating = False
FirstItem = ActiveCell.Value
SecondItem = ActiveCell.Offset(1, 0).Value
Offsetcount = 1
Do While ActiveCell <> ""
If FirstItem = SecondItem Then
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
|
Additional query words: 5.00 5.00c 7.00 8.00 xl97 double repeat
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |