In the example, the formula cell B4 of the helper column looks like this: This formula picks up the value in D4 and uses concatenation to add a hyphen, and the result of a COUNTIF function. The COUNTIF function uses an expanding range (the mixed reference $D$4:D4) to generate a running count of the id in the data. On the lookup side, VLOOKUP is used to fetch values form the table, taking into account the “nth” occurrence. The trick is to build a lookup value with the same structure as the values that appear in the helper column, taking into account “nth”. Again, this is done with concatenation, by adding a hyphen and a value that represents “nth” to a normal lookup value (pulled from the named range “id” in this case).

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.