Known variables: Number of rows, number of columns, number of cells, cell index.
Find: column number relative to cell index.
1 2 3 4 5 6 7 8 9
What function can I use to find that
6 is in column 2 and row 2?
For the row, you can use 1+floor((cell index-1)/number of columns)
For the column, 1+(cell index-1)% number of columns
The 1+ and -1 are reason to use a base of zero-then they go away.
Generally, if you have "end effects" like your 8%4=0 they can be handled by adding or subtracting to put the break where you want it.