SOLVED

# Combining 2 cells and if the result is duplicate add hyphen & running number

Copper Contributor

# Combining 2 cells and if the result is duplicate add hyphen & running number

Hi all,

I wonder if we can automatically add a hyphen and running number

I have a lot of data

Column A - Starting Code - Default "DFP"

Column B - Ending Code - These are numbers and some of them are duplicates

In Column C - I am going to combine A + B = But because B has duplicates the results in C will also end up having duplicates

I want another column Column D - to check duplicates and add a hyphen and running number (-1, -2, -3) if duplicates are found. Is it possible to do this in Excel?

2 Replies
best response confirmed by AnusornKh (Copper Contributor)
Solution

# Re: Combining 2 cells and if the result is duplicate add hyphen & running number

=IF(COUNTIF(\$C\$2:\$C\$7,C2)=1,"",C2&"-"&COUNTIF(\$C\$2:C2,C2))

This formula returns the intended result in my sheet.

# Re: Combining 2 cells and if the result is duplicate add hyphen & running number

Thank you!!

Worked like a charm
1 best response

Accepted Solutions
best response confirmed by AnusornKh (Copper Contributor)
Solution

# Re: Combining 2 cells and if the result is duplicate add hyphen & running number

=IF(COUNTIF(\$C\$2:\$C\$7,C2)=1,"",C2&"-"&COUNTIF(\$C\$2:C2,C2))

This formula returns the intended result in my sheet.