# Launch a macro when a shape is moved

#### LSA_1984

##### New Member
Hello,
Here my challenge:

I've placed 4 rectangles - one below each other (with a little bit of space inbetween). I've named them R1, R2, R3 and R4. There current position is
(...).Left = 60 (for all)
(...).Top = 60 (for R1), 80 (for R1), 100 (for R1) & 120 (for R1)

My goal is to be capable to re-order them by moving the shapes: if I click with my mouse on "R4" and move it up somewhere inbetween "R1" and "R2", I want (after releasing my mouse) to see "R1" staying at its first position, "R4" beeing at the second position (coordinates: .Left = 60 and .Top = 80), "R2" moving down to the 3rd position and "R3" moving down to the last position. New order beeing R1-R4-R2-R3.

My approach so far is to have two table: One providing the .Left and .Top coordinates for the 4 expected positions (reference table) and the other one gathering the .Left and .Top positions of the 4 rectangles. I can anytime (upon demand) check the real position of the 4 rectangles and decide, based on their real position, in which order I want to see them appearing in their respective positions. So if I move "R4" manually inbetween "R1" and "R2", my "real position table" will show that the .Top value for "R4" is now the second lowest => I can reorder the 4 rectangles as expected: "R1", "R4", "R2", "R3"

My problem: today i need to click on a buton to update the "real position table". I want the macro to start as soon as a position move has been detected.

Any suggestions? best practises?

Thank you

Laurent

### Excel Facts

Is there a shortcut key for strikethrough?
Ctrl+S is used for Save. Ctrl+5 is used for Strikethrough. Why Ctrl+5? When you use hashmarks to count |||| is 4, strike through to mean 5.

#### bobsan42

##### Well-known Member
the are several posts in this message board on this subject - Events for Shapes or something similar.
It is not naturally supported by VBA.

However check this link: Shape events in VBA
I have not yet tested it myself but it looks promissing.

#### LSA_1984

##### New Member
the are several posts in this message board on this subject - Events for Shapes or something similar.
It is not naturally supported by VBA.

However check this link: Shape events in VBA
I have not yet tested it myself but it looks promissing.
Thanks - I will have a look!

Replies
2
Views
535
Replies
2
Views
2K
Replies
0
Views
114
Replies
6
Views
322
Replies
1
Views
350

1,148,007
Messages
5,744,319
Members
423,861
Latest member
Ka3EeM

### We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.

### Which adblocker are you using?

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

### Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

### Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back