0

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
3
  • Question isn't exactly clear. Where are you getting the count from? Commented Oct 13, 2011 at 3:01
  • Are you saying, for example, the value IF4444 implies Cnt=2? If not, why is Cnt=2 the expected value on those rows? If we knew why Cnt is supposed to be 2 here, we might be able to tell you if Excel can do that. Commented Oct 13, 2011 at 3:12
  • 1
    Hi, The 'Number' field is is a list of records that I have generated from some database but I need to compute the 'Cnt' field one . Row 1 and Row 2 are with the same Number values so I have to set Cnt as 1 , Row 3 and 4 are another set of same Number values so I have to increment the Cnt to 2 and so on. I am not sure how to increment the 'Cnt' if the 'Number' fields are the same. Commented Oct 13, 2011 at 3:29

1 Answer 1

2

If the values in the Number column are sorted (i.e., grouped), you can do the following.

  1. Enter "1" in A2 (the first Cnt value).
  2. Enter =IF(B3=B2,A2,A2+1) in A3, where column B holds the Number values.
  3. Fill down the formula in A3.

If, however, the values in the Number column are NOT sorted, you will need to do the following:

  1. Enter "1" in A2.
  2. 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.
  3. Fill down the formula in A3.
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.