moving shapes with vba absolute X and Y coordinates

Lochnagar

New Member
Joined
Jan 28, 2008
Messages
43
Hi,

In a previous post I read, it mentioned that it's possible to specify absolute coordinates for an excel shape e.g. rectangle. I've tried recording a macro whilst moving a shape around but to no avail, see below,

ActiveSheet.Shapes("Rectangle 1").Select
Selection.ShapeRange.IncrementLeft -20
Selection.ShapeRange.IncrementTop -20


...and I've tried looking thru help, but I'm having difficulty working out what the appropriate commands are for absolute corrdinates instead of relative ones. So I was hoping someone might be able to point me in the right direction.

Any advise/help will, as always, be hugely appreciated.

Thanks,
Lochnagar.
 

Excel Facts

Save Often
If you start asking yourself if now is a good time to save your Excel workbook, the answer is Yes
Try something like this:

Code:
Public Sub Test()

Dim oShape As Shape

Set oShape = ActiveSheet.Shapes("Rectangle 1")

oShape.Top = 200
oShape.Left = 200

'or

'Move shape to top left corner of cell E10
Dim oCell As Range

Set oCell = ActiveSheet.Range("E10")

oShape.Top = oCell.Top
oShape.Left = oCell.Left


End Sub

Hope it helps.

Gary
 
Upvote 0
What about:
Code:
ActiveSheet.Shapes("Rectangle 1").Top = 45
ActiveSheet.Shapes("Rectangle 1").Left = 33
?
 
Upvote 0
i would like the user to drag a shape to certain cell, i.e. C4. If he drags it to a cell other than C4, an error message will appear... can someone help me with this...thanks!
 
Upvote 0

Forum statistics

Threads
1,223,264
Messages
6,171,081
Members
452,377
Latest member
bradfordsam

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.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

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

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

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
Back
Top