N Harkawat wrote...
IF your name range is in column A beginning from Column A2 type this
on
column B2 and copy it all the way down
=IF(COUNTIF($A$2:A2,A2)1,VLOOKUP(A2,$A1:B$2,2,0) ,MAX($B$1:B1)+1)
....
The issue with COUNTIF is that it'll iterate through all cells in its
1st argument range. MATCH with 0 3rd argument will return on finding
the first match.
Also, OP's data had names in col B and numbers in col A. In that case,
need to use INDEX(.,MATCH()) rather than VLOOKUP.
For one cell per result, try these formulas.
A1:
1
A2:
=1+(B2<B1)
A3:
=IF(ISERROR(MATCH(B3,B$1:B2,0)),MAX(A$1:A2)+1,
INDEX(A$1:A2,MATCH(B3,B$1:B2,0)))
Fill A3 down as needed.
For recalc efficiency, better to enter the MATCH calls and cache the
running max col A values in other columns, so 3 cells per result. A1
and A2 cells remain the same as above, but A3 down need 2 ancillary
cells (I'll use cols X and Y).
A3:
=IF(ISERROR(X3),MAX(A$1:A2)+1,INDEX(A$1:A2,X3))
X3:
=MATCH(B3,B$1:B2,0)
Y3:
=MAX(A1:A2)
Y4:
=Y3+ISERROR(X3)
Fill A3 and X3 down as needed, fill Y4 down as needed.
|