Two dimensional align and distribute using VBA?

I want to align and distribute objects two-dimensionally like below, similar to a grid. So that I don't have to select each row & column + grouping to align and distribute.

Previously Taras.SoftLV implemented an amazing macro that does this (link). However, it iterates each shape by its creation order. If the shapes placed weren't created in that order it would break the current arrangement. So the processed result looks like this:

How can we instead of iterating by creation order, iterate by the approximate position of each shape in the matrix, for example left to right, top to bottom?