if (app.selection.parent instanceof Cell)
row = app.selection.parent.parentRow.index;
The script should really also check whether you're you're in the last row of the table.
Thanks Peter. This is exactly what I needed to get going!
Something's going wrong when I apply it here to my table. It works fine on the first column, but otherwise it just keeps on skipping rows seemingly randomly.
LGFN1, do you have vertically split/merged cells in your table?
No, but I do have horizontally merged cells, if that matters.