Counting Duplicates

bhieatza

New Member
Joined
Apr 27, 2016
Messages
18
Okay this should be an easy one. I need to make a function or macro that counts duplicates. The last three characters are numbers. So if it comes across:
Milk_001
Milk_001
It would be changed to
Milk_001
Milk_002
The problem i am running into is when I get to the 10th duplicate it reads:
Milk_0010 instead of Milk_010.
Thank you for the help!
 

Excel Facts

Why does 9 mean SUM in SUBTOTAL?
It is because Sum is the 9th alphabetically in Average, Count, CountA, Max, Min, Product, StDev.S, StDev.P, Sum, VAR.S, VAR.P.

Book1
ABC
135Milk_001Milk_Milk_001
136Milk_001Milk_Milk_002
137Milk_001Milk_Milk_003
138Milk_001Milk_Milk_004
139Milk_001Milk_Milk_005
140Milk_001Milk_Milk_006
141Milk_001Milk_Milk_007
142Milk_001Milk_Milk_008
143Milk_001Milk_Milk_009
144Milk_001Milk_Milk_010
145Milk_001Milk_Milk_011
Blad1
Cell Formulas
RangeFormula
B135=LEFT(A135,LEN(A135)-3)
C135=B135&TEXT(COUNTIF($B$135:$B135,$B135),"000")
 
Upvote 0
ABC
Milk_001
Milk_001
Milk_001
Milk_001
Milk_001
Milk_001
Milk_001
Milk_001
Milk_001
Milk_001
Milk_001

<colgroup><col style="width: 25pxpx"><col><col><col></colgroup><thead>
</thead><tbody>
[TD="align: center"]135[/TD]

[TD="bgcolor: #FFFF00"]Milk_[/TD]
[TD="bgcolor: #92D050"]Milk_001[/TD]

[TD="align: center"]136[/TD]

[TD="bgcolor: #FFFF00"]Milk_[/TD]
[TD="bgcolor: #92D050"]Milk_002[/TD]

[TD="align: center"]137[/TD]

[TD="bgcolor: #FFFF00"]Milk_[/TD]
[TD="bgcolor: #92D050"]Milk_003[/TD]

[TD="align: center"]138[/TD]

[TD="bgcolor: #FFFF00"]Milk_[/TD]
[TD="bgcolor: #92D050"]Milk_004[/TD]

[TD="align: center"]139[/TD]

[TD="bgcolor: #FFFF00"]Milk_[/TD]
[TD="bgcolor: #92D050"]Milk_005[/TD]

[TD="align: center"]140[/TD]

[TD="bgcolor: #FFFF00"]Milk_[/TD]
[TD="bgcolor: #92D050"]Milk_006[/TD]

[TD="align: center"]141[/TD]

[TD="bgcolor: #FFFF00"]Milk_[/TD]
[TD="bgcolor: #92D050"]Milk_007[/TD]

[TD="align: center"]142[/TD]

[TD="bgcolor: #FFFF00"]Milk_[/TD]
[TD="bgcolor: #92D050"]Milk_008[/TD]

[TD="align: center"]143[/TD]

[TD="bgcolor: #FFFF00"]Milk_[/TD]
[TD="bgcolor: #92D050"]Milk_009[/TD]

[TD="align: center"]144[/TD]

[TD="bgcolor: #FFFF00"]Milk_[/TD]
[TD="bgcolor: #92D050"]Milk_010[/TD]

[TD="align: center"]145[/TD]

[TD="bgcolor: #FFFF00"]Milk_[/TD]
[TD="bgcolor: #92D050"]Milk_011[/TD]

</tbody>
Blad1

[TABLE="width: 85%"]
<tbody>[TR]
[TD]Worksheet Formulas[TABLE="width: 100%"]
<thead>[TR="bgcolor: #DAE7F5"]
[TH="width: 10px"]Cell[/TH]
[TH="align: left"]Formula[/TH]
[/TR]
</thead><tbody>[TR]
[TH="width: 10px, bgcolor: #DAE7F5"]B135[/TH]
[TD="align: left"]=LEFT(A135,LEN(A135)-3)[/TD]
[/TR]
[TR]
[TH="width: 10px, bgcolor: #DAE7F5"]C135[/TH]
[TD="align: left"]=B135&TEXT(COUNTIF($B$135:$B135,$B135),"000")[/TD]
[/TR]
</tbody>[/TABLE]
[/TD]
[/TR]
</tbody>[/TABLE]

Wow. I am upset I did not think of that haha. Thanks for your help.
 
Upvote 0
ABC
Milk_001
Milk_001
Milk_001
Milk_001
Milk_001
Milk_001
Milk_001
Milk_001
Milk_001
Milk_001
Milk_001

<colgroup><col style="width: 25pxpx"><col><col><col></colgroup><thead>
</thead><tbody>
[TD="align: center"]135[/TD]

[TD="bgcolor: #FFFF00"]Milk_[/TD]
[TD="bgcolor: #92D050"]Milk_001[/TD]

[TD="align: center"]136[/TD]

[TD="bgcolor: #FFFF00"]Milk_[/TD]
[TD="bgcolor: #92D050"]Milk_002[/TD]

[TD="align: center"]137[/TD]

[TD="bgcolor: #FFFF00"]Milk_[/TD]
[TD="bgcolor: #92D050"]Milk_003[/TD]

[TD="align: center"]138[/TD]

[TD="bgcolor: #FFFF00"]Milk_[/TD]
[TD="bgcolor: #92D050"]Milk_004[/TD]

[TD="align: center"]139[/TD]

[TD="bgcolor: #FFFF00"]Milk_[/TD]
[TD="bgcolor: #92D050"]Milk_005[/TD]

[TD="align: center"]140[/TD]

[TD="bgcolor: #FFFF00"]Milk_[/TD]
[TD="bgcolor: #92D050"]Milk_006[/TD]

[TD="align: center"]141[/TD]

[TD="bgcolor: #FFFF00"]Milk_[/TD]
[TD="bgcolor: #92D050"]Milk_007[/TD]

[TD="align: center"]142[/TD]

[TD="bgcolor: #FFFF00"]Milk_[/TD]
[TD="bgcolor: #92D050"]Milk_008[/TD]

[TD="align: center"]143[/TD]

[TD="bgcolor: #FFFF00"]Milk_[/TD]
[TD="bgcolor: #92D050"]Milk_009[/TD]

[TD="align: center"]144[/TD]

[TD="bgcolor: #FFFF00"]Milk_[/TD]
[TD="bgcolor: #92D050"]Milk_010[/TD]

[TD="align: center"]145[/TD]

[TD="bgcolor: #FFFF00"]Milk_[/TD]
[TD="bgcolor: #92D050"]Milk_011[/TD]

</tbody>
Blad1

[TABLE="width: 85%"]
<tbody>[TR]
[TD]Worksheet Formulas[TABLE="width: 100%"]
<thead>[TR="bgcolor: #DAE7F5"]
[TH="width: 10px"]Cell[/TH]
[TH="align: left"]Formula[/TH]
[/TR]
</thead><tbody>[TR]
[TH="width: 10px, bgcolor: #DAE7F5"]B135[/TH]
[TD="align: left"]=LEFT(A135,LEN(A135)-3)[/TD]
[/TR]
[TR]
[TH="width: 10px, bgcolor: #DAE7F5"]C135[/TH]
[TD="align: left"]=B135&TEXT(COUNTIF($B$135:$B135,$B135),"000")[/TD]
[/TR]
</tbody>[/TABLE]
[/TD]
[/TR]
</tbody>[/TABLE]

Is this possible to do for multiple things such as:
Milk_001
Grapes_001
Milk_001
Grapes_001
Milk_001
Corn_001
Grapes_001

Goes to:
Milk_001
Grapes_001
Milk_002
Grapes_002
Milk_003
Corn_001
Grapes_003
???
 
Upvote 0
Yes off course, same concept.


Book1
ABC
155Milk_001Milk_Milk_001
156Grapes_001Grapes_Grapes_001
157Milk_001Milk_Milk_002
158Grapes_001Grapes_Grapes_002
159Milk_001Milk_Milk_003
160Corn_001Corn_Corn_001
161Grapes_001Grapes_Grapes_003
Blad1
Cell Formulas
RangeFormula
B155=LEFT(A155,LEN(A155)-3)
C155=B155&TEXT(COUNTIF($B$155:$B155,$B155),"000")
 
Upvote 0

Forum statistics

Threads
1,223,214
Messages
6,170,772
Members
452,353
Latest member
strainu

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