Home » excel » Excel Formula for A, B, C grouping and find first occurrences?

# Excel Formula for A, B, C grouping and find first occurrences?

Questions:

I have this table like below: The end result I want to achieve is:

• If there is One and only one group code in Column E, then the
sub-group code should show only that value without A,B,C.
• If there are two group codes in column E, then the sub-group code
should show groupcode A and groupcode B.
• If there are three group codes in column E, then the sub-group code should show groupcode A, groupcode B, and groupcode C.

========================================================================

Now as you can see in the table, I can only achieve 1003A (correct), but the second value should be 1003B instead of 1003C.

Here’s my formula:

``````=IF(COUNTIF([Group Code],[@[Group Code]])=1, [@[Group Code]],
IF(((COUNTIF(\$E\$4:\$E7,[@[Group Code]])=1)+0)=1, [@[Group Code]]&"A",
IF(((COUNTIF(\$E\$4:\$E7,[@[Group Code]])=2)+0)=2, [@[Group Code]]&"B",
[@[Group Code]]&"C")))
``````

Anybody knows how do I tweak this code to produce the desirable result?
Thanks so much!

``````=IF(COUNTIF(E\$4:E\$8,E4)=1,E4,E4&CHAR(COUNTIF(E\$4:E4,E4)+64)) 