find duplicate-create new column-write number coding

elba7312

New Member
Joined
Jun 3, 2011
Messages
7
Hi all,
Please I would like you to help me in creating a VBA code for:
1- find duplication in column B (file is attached)


-- removed inline image ---
[/INDENT]Thanks a lot for help
 

Excel Facts

Difference between two dates
Secret function! Use =DATEDIF(A2,B2,"Y")&" years"&=DATEDIF(A2,B2,"YM")&" months"&=DATEDIF(A2,B2,"MD")&" days"
You could do this without VBA by using a formula like this

=COUNTIF($B:$B, B2)&COUNTIF($B$2:B2, B2)
 
Upvote 0
dave3009 beat me to it with the formula, you can make it into a macro:
Code:
Sub blah()
With Range(Range("B2"), Range("B2").End(xlDown)).Offset(, 1)
  .FormulaR1C1 = "=COUNTIF(C2,RC2) & COUNTIF(R2C2:RC2,RC2)"
.Value = .Value
End With
End Sub
I wonder whether you'll be able to interpret what's happening when you get above 10 instances, perhaps add a space:
Code:
Sub blah2()
With Range(Range("B2"), Range("B2").End(xlDown)).Offset(, 1)
    .FormulaR1C1 = "=COUNTIF(C2,RC2) & "" "" & COUNTIF(R2C2:RC2,RC2)"
.Value = .Value
End With
End Sub
or formula:
=COUNTIF($B:$B,$B2) & " " & COUNTIF($B$2:$B2,$B2)
copied down from C2.
 
Last edited:
Upvote 0

Forum statistics

Threads
1,224,558
Messages
6,179,512
Members
452,921
Latest member
BBQKING

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