Numbering unique values in a worksheet

2019-08-02 09:36发布

I have a list of members (people) of an association.

Some member companies have one member others a=have many.

I need to number the unique/distinct companies.

For example. Here is a list of lines from the worksheet.

ABC Inc
ABC Inc
ABC Inc
Big Top LLC
Big Top LLC
Callhans PLLC
Callhans PLLC
Callhans PLLC
Callhans PLLC
Callhans PLLC
Callhans PLLC
Callhans PLLC
Callhans PLLC
Callhans PLLC
Callhans PLLC
Davis & Davis
Eaden Supply
Eaden Supply
Eaden Supply

I would like to number each company as such

ABC Inc 1
ABC Inc 1
ABC Inc 1
Big Top LLC 2
Big Top LLC 2
Callhans PLLC   3
Callhans PLLC   3
Callhans PLLC   3
Callhans PLLC   3
Callhans PLLC   3
Callhans PLLC   3
Callhans PLLC   3
Callhans PLLC   3
Callhans PLLC   3
Callhans PLLC   3
Davis & Davis   4
Eaden Supply    5
Eaden Supply    5
Eaden Supply    5

Can anybody help me out with a formula? I'm on a mac so no VBA please.

标签: excel
2条回答
在下西门庆
2楼-- · 2019-08-02 09:56

If you data is not sorted, then you can use this approach. Enter this formula =IF(COUNTIF(A$2:A2,A2)=1,MAX(B$1:B1)+1,VLOOKUP(A2,A$1:B1,2,0)) in B2 cell and drag it to the end. enter image description here

查看更多
Rolldiameter
3楼-- · 2019-08-02 10:11

Put the number 1 in the first cell (B1), then put this formula below it and drag it down:

=IF(A2=A1,B1,B1+1)

Formula

查看更多
登录 后发表回答