jackadmin
asked on
Append unique number to duplicate cells
I have a Excel spreadsheet with item names in column C. I need to add a unique number suffix to each name for any duplicate names in column C. I can create additional columns to accomplish this. The new name should appear in column D.
The formula below works to append the total number of duplicates to the end of the name (if greater than one). However, I need this to append a unique number.
=IF(COUNTIF($C$2:$C$2000,C 52)>1,C52& "-"&COUNTI F($C$2:$C$ 2000,C52))
For example, what I need is:
COLUMN C
FRANK
FRANK
FRANK
FRANK
FRANK
COLUMN D
FRANK -1
FRANK -2
FRANK -3
FRANK -4
FRANK -5
The formula below works to append the total number of duplicates to the end of the name (if greater than one). However, I need this to append a unique number.
=IF(COUNTIF($C$2:$C$2000,C
For example, what I need is:
COLUMN C
FRANK
FRANK
FRANK
FRANK
FRANK
COLUMN D
FRANK -1
FRANK -2
FRANK -3
FRANK -4
FRANK -5
ASKER
Thomas,
When I do that, I just get
FRANK -0
for each result
When I do that, I just get
FRANK -0
for each result
Thomas's formula works for me if the data starts in row 52 (as per your original formula). I suspect, however, that your data actually starts in C2?
In which case, just change the instances of C52 in Thomas's formual to C2.
=IF(COUNTIF($C$2:$C$2000,C 2)>1,C2&"- "&COUNTIF( $C$2:$C2,C 2))
(If this works, points to Thomas plz)
In which case, just change the instances of C52 in Thomas's formual to C2.
=IF(COUNTIF($C$2:$C$2000,C
(If this works, points to Thomas plz)
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
(no points - just providing additional explanation)
@NB_VC - Good addition with the trailing ",$C2".
=IF(COUNTIF($C$2:$C$2000,C 2)>1,C2&"- "&COUNTIF( $C$2:$C2,$ C2),$C2)
The original formula neglects the fact that there may be only a single instance of a value in the list, which would cause a result of "FALSE" since the 2nd IF action isn't defined. Nice catch.
@NB_VC - Good addition with the trailing ",$C2".
=IF(COUNTIF($C$2:$C$2000,C
The original formula neglects the fact that there may be only a single instance of a value in the list, which would cause a result of "FALSE" since the 2nd IF action isn't defined. Nice catch.
ASKER
This worked perfectly. Thank you.
=IF(COUNTIF($C$2:$C$2000,C
Thomas