How do I increment the row count (Cnt
) based on the Number column in Excel? Are there any formulas that I can use to generate the Cnt
column?
Cnt Number开发者_如何学编程
1 IF1234
1 IF1234
2 IF4444
2 IF4444
3 IF5555
3 IF5555
If the values in the Number column are sorted (i.e., grouped), you can do the following.
- Enter "1" in A2 (the first Cnt value).
- Enter
=IF(B3=B2,A2,A2+1)
in A3, where column B holds the Number values. - Fill down the formula in A3.
If, however, the values in the Number column are NOT sorted, you will need to do the following:
- Enter "1" in A2.
- Enter
=IF(ISERROR(MATCH(B3,B$2:B2,0)),MAX(A$2:A2)+1,INDEX(A$2:A2,MATCH(B3,B$2:B2,0)))
in A3. - Fill down the formula in A3.
精彩评论