This might give you food for thought.
Make your box on a new layer > Fill it with any colour > and make it a Smart Object.
Make as many copies as you need rows, and use Move > Align to equally space them.
Place thouse layers in a Group, and repeat the last steps to make the colums.

If you double click any of the Smart Objects to open it in a new window, and run your gradient, the other Smart Objects will be updated, thus

If, on the other hand, you wanted a single gradient to cover the boxes, them select all the groups, and make that a smart object. That effectivel;y puts them all into a single layer.
You can now run a gradient in a new layer and clip it to that Smart Object.
You can still double click the Smart Object to edit it.

You could also add a layer mask to the gradient layer, and mask some of the layer to reveal the original gradients.

If we/I are missing your point, give us some more details and someone will work it out with you.