ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Worksheet Functions (https://www.excelbanter.com/excel-worksheet-functions/)
-   -   Restart row count each time the value in a specific column changes (https://www.excelbanter.com/excel-worksheet-functions/203476-restart-row-count-each-time-value-specific-column-changes.html)

RC

Restart row count each time the value in a specific column changes
 
Is there a formula that will restart the row count when the value in a
specific column changes --- such as shown below when the value in column A
changes the row count in column B restarts?

A B
1 452 1
2 452 2
3 452 3
4 452 4
5 329 1
6 329 2
7 548 1
8 548 2
9 548 3

Thanks in advance

--
RC

ExcelBanter AI

Answer: Restart row count each time the value in a specific column changes
 
  1. Insert a new column next to column B (let's say it's column C).
  2. In cell C1, enter the formula: =IF(A1<A2,1,B1+1)
  3. Drag the formula down to the last row of your data.
  4. Column C will now display the row count that restarts each time the value in column A changes.

Explanation of the formula:
- IF(A1<A2,1,B1+1): This formula checks if the value in cell A1 is different from the value in cell A2. If it is, it means that the value in column A has changed, so it resets the row count to 1. If it's not different, it means that the value in column A is the same as the previous row, so it adds 1 to the row count in the previous row (cell B1).

Max

Restart row count each time the value in a specific column changes
 
Here's one ..
In B1, copied down: =COUNTIF(A$1:A1,A1)
--
Max
Singapore
http://savefile.com/projects/236895
Downloads:18,100 Files:360 Subscribers:56
xdemechanik
---
"RC" wrote:
Is there a formula that will restart the row count when the value in a
specific column changes --- such as shown below when the value in column A
changes the row count in column B restarts?

A B
1 452 1
2 452 2
3 452 3
4 452 4
5 329 1
6 329 2
7 548 1
8 548 2
9 548 3

Thanks in advance

--
RC


RC

Restart row count each time the value in a specific column cha
 
Thanks Max, that works great!
--
RC


"Max" wrote:

Here's one ..
In B1, copied down: =COUNTIF(A$1:A1,A1)
--
Max
Singapore
http://savefile.com/projects/236895
Downloads:18,100 Files:360 Subscribers:56
xdemechanik
---
"RC" wrote:
Is there a formula that will restart the row count when the value in a
specific column changes --- such as shown below when the value in column A
changes the row count in column B restarts?

A B
1 452 1
2 452 2
3 452 3
4 452 4
5 329 1
6 329 2
7 548 1
8 548 2
9 548 3

Thanks in advance

--
RC


Max

Restart row count each time the value in a specific column cha
 
Welcome, thanks for feeding back
--
Max
Singapore
http://savefile.com/projects/236895
Downloads:18,000 Files:359 Subscribers:56
xdemechanik
---
"RC" wrote in message
...
Thanks Max, that works great!
--
RC





All times are GMT +1. The time now is 09:06 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com