Reputation: 13
I have a large data set based on tag numbers:
tag | value 1 | value 2 | ... | value 20| comment |
------------------------------------------------------------
01 | data | data | data | data | red |
02 | data | data | data | data | blue |
03 | data | data | data | data | purple |
04 | data | data | data | data | green |
04 | data | data | data | data | green |
.
.
03 | data | data | data | data | purple |
I would like to check the 'tag' column for duplicate values, and if found, append the word 'duplicate' to the comment, without using an extra column for the calculation. For the table above, the result would be:
tag | value 1 | value 2 | ... | value 20| comment |
--------------------------------------------------------------------
01 | data | data | data | data | red |
02 | data | data | data | data | blue |
03 | data | data | data | data | purple |
04 | data | data | data | data | green |
04 | data | data | data | data | green - duplicate |
.
.
03 | data | data | data | data | purple - duplicate |
Is this possible? If so, please provide an example.
Upvotes: 0
Views: 1554
Reputation: 96753
If your data is like:
Then this short macro should do it:
Sub DupFinder()
Dim wf As WorksheetFunction, i As Long
Set wf = Application.WorksheetFunction
For i = 1 To Cells(Rows.Count, 1).End(xlUp).Row
If wf.CountIf(Range(Cells(i, 1), Cells(1, 1)), Cells(i, 1).Value) > 1 Then
Cells(i, "V").Value = Cells(i, "V").Value & " Duplicate"
End If
Next i
End Sub
This assumes that the comment column is column V
Upvotes: 1