Excel Snippets: Generate Row Numbers

MicrosoftI might not post many Excel snippets, but I’m collecting them into a small Excel Snippets series to make them easy to find.

A while ago, I posted an article on < ahref='https://www.azurecurve.co.uk/2017/06/sql-snippet-generate-row-numbers/'>generating row umbers in a SQL script; I fielded a question from someone recently on doing the same thing Excel where the row number changes based on two columns of data. Basically when either of the columns were different, the row number should reset back to 1.

The following formula uses an IF combined with an OR to check if either column of data is different to the row above and if so sets the row number to 1 otherwise it increments by 1: