set shape size from cell data

gergo

New Member
Joined
Apr 6, 2012
Messages
2
I would like to make a macro which inserts a square shape with the dimensions earned from a cell.
For example A1 says 5 and B1 says 2. So I'd like to set square height to A1 so it will be 5. and widht to B1 so it will be 2.
So whenever I change values in A1 and B2 and rerun the macro it would create a new square shape with the new values.
Is it possible?

Thanks in advance :D
 

Excel Facts

Lock one reference in a formula
Need 1 part of a formula to always point to the same range? use $ signs: $V$2:$Z$99 will always point to V2:Z99, even after copying
That would be an exceedingly small rectangle!

Maybe like this

Code:
Sub test()
Dim sh As Object
Set sh = ActiveSheet.Shapes.AddShape(msoShapeRectangle, Range("E3").Left, Range("E3").Top, Range("B1").Value * 10, Range("A1").Value * 10)
End Sub
 
Upvote 0

Forum statistics

Threads
1,216,098
Messages
6,128,812
Members
449,468
Latest member
AGreen17

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