When copied down the column, this formula will return a running count for each color in the Color column. In some versions of Excel, this is an array formula and must be entered with control + shift + enter. On the left side of the colon (:), the INDEX function returns a reference to the first cell in the column. This works because, the INDEX function returns a reference to the first cell, not the actual value. On the right side of the colon, we get a reference to the current row of the color column like this: This is the standard structured reference syntax for “this row”. Joined with the colon, these two references create a range that expands as the formula is copied down the table. So, we swap these references into the SUM function, we have: Each of the expressions above generates an array of TRUE/FALSE values, and the double negative (–) is used to convert these values to 1s and 0s. So, in the last row, we end up with: The rest of the formula simply concatenates the color from the current row to the count returned by SUM:
Simple expanding range?
Why not use a simple expanding range like this? For some reason, this kind of mixed reference becomes corrupted in an Excel Table as rows are added. Using INDEX with a structured reference solves the problem.
Dave Bruns
Hi - I’m Dave Bruns, and I run Exceljet with my wife, Lisa. Our goal is to help you work faster in Excel. We create short videos, and clear examples of formulas, functions, pivot tables, conditional formatting, and charts.