You could autoindex on the array of rows on a FOR loop and replace the correct element at each iteration. Make sure to keep the array in a shift register.
There are many easy ways to do that, but since you did not show us any code, we cannot tell what you are doing wrong. Please show us what you got so far...