hi i have sorted the category but it is working fine i am attaching the file.
Hello,
If the ID is always in the same format, starting with M & four digits, try this in D3, then copy down.
=C3&COUNTIFS(A:A,"<"&A3,C:C,C3)+1
If the ID starting alpha is different & last four character are digits, try this
=C3&SUMPRODUCT((C$3:C$22=C3)*(RIGHT(A3,4)+0>RIGHT(A$3:A$22,4)+0))+1