Excel - Macro to highlight Rows with Duplicate values in a cell
Solved/Closed
ajaydwivediji
Posts
9
Registration date
Tuesday October 30, 2012
Status
Member
Last seen
January 5, 2017
-
Oct 30, 2012 at 06:26 AM
TrowaD Posts 2921 Registration date Sunday September 12, 2010 Status Contributor Last seen December 27, 2022 - Jan 19, 2015 at 12:06 PM
TrowaD Posts 2921 Registration date Sunday September 12, 2010 Status Contributor Last seen December 27, 2022 - Jan 19, 2015 at 12:06 PM
Related:
- How do you highlight rows with different colors by groups of duplicates?
- Can you make a close friends highlight - Instagram Forum
- Will itunes import duplicates - Guide
- Sound card colors - Guide
- How do you highlight a message on whatsapp ✓ - WhatsApp Forum
- Instagram highlight not loading - Instagram Forum
7 responses
TrowaD
Posts
2921
Registration date
Sunday September 12, 2010
Status
Contributor
Last seen
December 27, 2022
555
Aug 22, 2013 at 10:29 AM
Aug 22, 2013 at 10:29 AM
Hi Stalin,
Take a look at the following sample data (column B):
abc
abc
def
ghi
ghi
ghi
ghi
jkl
If you want the result to be 2 (abc and ghi are counted as duplicates) then the following code will do the trick:
If this isn't what you meant, then please provide some sample data of your own along with the desired result.
Best regards,
Trowa
Take a look at the following sample data (column B):
abc
abc
def
ghi
ghi
ghi
ghi
jkl
If you want the result to be 2 (abc and ghi are counted as duplicates) then the following code will do the trick:
Sub test()
Dim x, cDup, lRow As Integer, skipDup As String
lRow = Range("B1").End(xlDown).Row
x = 1
cDup = 0
Do
x = x + 1
If Cells(x, "B").Value = Cells(x - 1, "B").Value And skipDup <> Cells(x, "B").Value Then
cDup = cDup + 1
skipDup = Cells(x, "B").Value
End If
Loop Until x = lRow + 1
MsgBox "Column B contains " & cDup & " Duplicates."
End Sub
If this isn't what you meant, then please provide some sample data of your own along with the desired result.
Best regards,
Trowa