Duplicates VBA

emukiss10

Board Regular
Joined
Nov 17, 2017
Messages
201
Hello!

Duplicates.

In Column F I have different numbers. The numbers are sorted ASC. I would like to have VBA script:

If a number occure in column F more than once, I want to put "DOUBLE" in column "V" in according row but only for second value and so on (first must not be marked. Colors are just for pointers - does not matter)

Range of my table is dynamic and lastRow should be determined by column F.

[TABLE="class: grid, width: 500"]
<tbody>[TR]
[TD="align: center"]A[/TD]
[TD="align: center"]F[/TD]
[TD="align: center"]G[/TD]
[TD="align: center"]H[/TD]
[TD="align: center"]V[/TD]
[/TR]
[TR]
[TD="align: center"]someName[/TD]
[TD="align: center"]11[/TD]
[TD="align: center"]data[/TD]
[TD="align: center"]Phone[/TD]
[TD="align: center"][/TD]
[/TR]
[TR]
[TD="align: center"]someName[/TD]
[TD="align: center"]22[/TD]
[TD="align: center"]data[/TD]
[TD="align: center"]Phone[/TD]
[TD="align: center"][/TD]
[/TR]
[TR]
[TD="align: center"]someName[/TD]
[TD="align: center"]33[/TD]
[TD="align: center"]data[/TD]
[TD="align: center"]Phone[/TD]
[TD="align: center"][/TD]
[/TR]
[TR]
[TD="align: center"]someName[/TD]
[TD="align: center"]33[/TD]
[TD="align: center"]data[/TD]
[TD="align: center"]Phone[/TD]
[TD="align: center"]DOUBLE[/TD]
[/TR]
[TR]
[TD="align: center"]someName[/TD]
[TD="align: center"]44[/TD]
[TD="align: center"]data[/TD]
[TD="align: center"]Phone[/TD]
[TD="align: center"][/TD]
[/TR]
[TR]
[TD="align: center"]someName[/TD]
[TD="align: center"]55[/TD]
[TD="align: center"]data[/TD]
[TD="align: center"]Phone[/TD]
[TD="align: center"][/TD]
[/TR]
[TR]
[TD="align: center"]someName[/TD]
[TD="align: center"]66[/TD]
[TD="align: center"]data[/TD]
[TD="align: center"]Phone[/TD]
[TD="align: center"][/TD]
[/TR]
[TR]
[TD="align: center"]someName[/TD]
[TD="align: center"]66[/TD]
[TD="align: center"]data[/TD]
[TD="align: center"]Phone[/TD]
[TD="align: center"]DOUBLE[/TD]
[/TR]
[TR]
[TD="align: center"]someName[/TD]
[TD="align: center"]66[/TD]
[TD="align: center"]data[/TD]
[TD="align: center"]Phone[/TD]
[TD="align: center"]DOUBLE[/TD]
[/TR]
</tbody>[/TABLE]

Please help me :)

Best Regards
W.
 

Excel Facts

How to find 2nd largest value in a column?
MAX finds the largest value. =LARGE(A:A,2) will find the second largest. =SMALL(A:A,3) will find the third smallest
How about
Code:
Sub AddDouble()

   Dim Cnt As Long
   
   For Cnt = Range("F" & Rows.Count).End(xlUp).Row To 3 Step -1
      If Range("F" & Cnt).Value = Range("F" & Cnt - 1).Value Then Range("V" & Cnt).Value = "DOUBLE"
   Next Cnt
End Sub
 
Upvote 0
Glad to help & thanks for the feedback
 
Upvote 0

Forum statistics

Threads
1,223,228
Messages
6,170,876
Members
452,363
Latest member
merico17

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top