There are many ways to do it, but you can just make 4 loops like so:
Do While Shapes("a").Left - 3 > Shapes("b").Left Shapes("a").Left = Shapes("a").Left - 1LoopDo While Shapes("a").Left + 3 < Shapes("b").Left Shapes("a").Left = Shapes("a").Left + 1LoopDo While Shapes("a").Top - 3 > Shapes("b").Top Shapes("a").Top = Shapes("a").Top - 1LoopDo While Shapes("a").Top + 3 < Shapes("b").Top Shapes("a").Top = Shapes("a").Top + 1Loop
Shape "a" follows shape "b". I set an offset of 3, because otherwise it would never stop. The position can sometimes not be exact, to fix that you'll need a condition when the distance is less than 1 and add the value of distance to Left and Top, correspondingly.
thanks,
I shared the forum for others from unipower
Hi UniPower and welcome to the Forum,
There are many ways to do it, but you can just make 4 loops like so:
Do While Shapes("a").Left - 3 > Shapes("b").Left Shapes("a").Left = Shapes("a").Left - 1 Loop Do While Shapes("a").Left + 3 < Shapes("b").Left Shapes("a").Left = Shapes("a").Left + 1 Loop Do While Shapes("a").Top - 3 > Shapes("b").Top Shapes("a").Top = Shapes("a").Top - 1 Loop Do While Shapes("a").Top + 3 < Shapes("b").Top Shapes("a").Top = Shapes("a").Top + 1 Loop
Shape "a" follows shape "b". I set an offset of 3, because otherwise it would never stop. The position can sometimes not be exact, to fix that you'll need a condition when the distance is less than 1 and add the value of distance to Left and Top, correspondingly.