How to add a row number to an Excel table

Excel tables provide a lot of support for data processing and the use of structured references can improve readability.

We want to number rows in an Excel table and we can do it really easily using structured references.

=ROW(Table01[@])-ROW(Table01[[#Headers],[RowId]])

We simply find the row number of the current cell [@] using ROW and then subtract the row number of the column title in the table header. Excel auto-completes the formula as you type and click.

  1. Type “=ROW([@]) -Row(“
  2. then click the table header
  3. Excel enters the cell reference.
  4. Close the brackets and click Enter
  5. job done.

range2

— Update 2020-04-18 —

See my more recent post for an alternative method that uses Power Query Editor.

9 responses to “How to add a row number to an Excel table”

  1. Excellent! I have been looking for this kind of solution for some time.

    Now, I have a couple of questions:
    1) How to sort the table by column without recalculating row numbers – is this possible at all?
    2) How to refer to table cell from outside, using the table row number and column name rather than the sheet cell coordinates?

    Many thanks in advance.
    Abbas

  2. 1) Yes. Create an new column RowFixed and copy and paste value into it. Use it for sorting
    2) I think either OFFSET or INDEX is your friend. You will need to have a go

    Good luck

  3. Dr James
    Million thanks for this!! –
    Have been losing my sleep over how to have Data Table specific Row Numbers!

  4. =ROW()-ROW(Table1[#Headers])
    works inside the table.
    Thanks for this inspiration.

  5. I was hoping not to need Table1 but it seems to insist on that despite being inside the table; wonder if I missed something. Also pondering how to make it immutable for sorting, but as you say, paste value for now.

Leave a reply to brentlightsey Cancel reply