Hello I am not sure that I clearly perceive your objective. What global variables are you talking about? However, the joined macro inserts a component into an open assembly, moves it, and saves the parameters of the move as variables in the Equations branch...
Why bother with macros when @max59 has surely given you the easiest solution. All you have to do is put an equation on the repetition values in both directions and you think you're done. Possibly one or two constants if you want to have fun (to define the 2 steps for example).
At worst of worst if the Solidworks equations don't work (because you want something more complex), you can always go through an Excel part family.
Nb: Since we are mechanically welded, there may be small subtleties for the equations. You probably have to create the basic bodies (the outer frame, the pilot sketch, the 2 or 3 bodies that repeat themselves), then do body repetitions.