How to quickly count the number of cells until value changes in Excel?
Count cells until value changes with formula
Count cells until value changes with PivotTable
Count cells until value changes with Kutools for Excel
Here is a simple formula can help you to quickly count the number of cells until value changes.
Select a blank cell next to the values you want to count, enter this formula =COUNTIF(A$1:A1,A1) and drag auto fill handle over the cells needed this formula. See screenshot:
Tip: in this formula, A1 is the cell you want to count, you can change it as you need.
With PivotTable function, you also can count the cells until value changes.
1. Select this value range, and click Insert > PivotTable, and in the popping dialog, check New Worksheet or Existing Worksheet option as you need in the Choose where you want the PivotTable report to be placed section. See screenshot:
2. In the popping out PivotTable Fields pane, add the column to the Rows section and Values section, now you can see the number of each value has been counted in the Pivot table. See screenshot:
Tip: The data range you want to use must have a data header.
If you have Kutools for Excel, a handy and useful add in tool with its Advanced Combine Rows utility, you can quickly count the cells until value changes, and also can do other calculation and operation.
|Kutools for Excel, with more than 300 handy functions, makes your jobs more easier.|
After free installing Kutools for Excel, please do as below:
1. First of all, you need to add a column next to the values you want to count, and fill the cells with 1. See screenshot:
Tip: you had better to save a copy of the original before applying Advanced Combine Rows utility.
2. Select the two columns and click Kutools > Merge & Split > Advanced Combine Rows. See screenshot:
3. In the Advanced Combine Rows dialog, select the column you want to count and click Primary Key, and then select the column you add, and choose Sum from the Calculation list. See screenshot:
4. Click Ok. And the values have been counted.