This is one way to do it:
I put a number 1 in the first row. Then in cell A2 (this is assuming the numbers are in column A, and names in B):
Code:
=IF(B2="","",IF(COUNTIF($B$1:B2,B2)>1,INDEX($A$1:A1,MATCH(B2,$B$1:$B$100,0)),MAX($A$1:A1)+1))
Try that and let me know if it works.