Numbering/sequencing sets of same column values

前端 未结 2 1717
温柔的废话
温柔的废话 2020-12-20 08:36

How to do numbering/sequencing for sets of same column values? For example:

Col1 Col2
Andy  1
Chad  1
Bill  1 
Andy  2
Bill  2
Bill  3
Chad  2
Bill  4


        
相关标签:
2条回答
  • 2020-12-20 09:22

    That is kind of slow when your list is really long. I've found sorting the column A to Z or small to larger and then using this formula is much faster:

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

    Basically if the value above is the same then add one to the count else start over at 1

    0 讨论(0)
  • 2020-12-20 09:25

    You can accomplish this with countif and a sliding range :

       A        B
    1  val1     =COUNTIF($A$1:A1, A1)
    2  valx     =COUNTIF($A$1:A2, A2)
    

    and so on.

    The formula in column B can be dragged down / autofilled in the column. It anchors to the start of the range and only looks as far down as the value we are numbering; COUNTIF is tallying up the matching values in the preceding set this way.

    0 讨论(0)
提交回复
热议问题