Google-sheets – Count iteration of random entries

formulasgoogle sheets

On my spreadsheet I have a list of 20 items. Each item is assigned a number, and I use a random number generator to randomly select one item from the list of 20 and display it in an adjacent cell.

I would like to have an additional number next to each item on the list which increases by 1 every time that item is selected. How can I use formulas to count the iterations of each item on the list?

Best Answer

Possible but in general inadvisable to do so with formulae only. Say your list is in A1 to A20 and the selection is made in C1.

In File > Spreadsheet settings... > Calculation set Recalculation to On change and turn On iterative calculation with Max. number of iterations set to 1.

Temporarily disable the formula in C1 and in B1 enter:

=B1+(C$1=A1)

and extend the series down to suit, then re-enable the formula in C1.