Square grid

I want to make a square grid of fixed side length but varying grid number using code.
That is, the number of grids should be specified by the user (say 33) and after pressing a button, the stage should be broken into 33 grids.

I don’t want any code, just a method on how to do it. I have tried it by using simple loops but the method just fails for no reason I can figure.