Macro Rectangle Positioning

kartrak

New Member
Joined
Dec 12, 2012
Messages
2
Hi,

I am a total VB newbie -with some googling, i have managed to draw 3 rectangles (3 macros) whose dimensions are picked from cells.

I want to be able to position them such that the 3 rectangles share the same bottom-left coordinates (0,0).

Also, i have written a macro to generate all 3 at once. in this case, i want them in an order - Rectangle 1 in background, rect 2 overlapping it and rect 3 overlapping rect2, with all three having same left/bottom origin. the three rectangles area will ALWAYS be in descending order.

any help would be very much appreciated....

the 3 drawing code :

Sub drawrated()

Dim length As Integer


length = Worksheets("Data").Range("$b$2").Value

Dim width As Integer


width = Worksheets("Data").Range("$c$2").Value

With ActiveSheet
.Shapes.AddShape(msoShapeRectangle, 100, 100, length, width).Select
End With


End Sub


Sub drawplanned()

Dim length As Integer


length = Worksheets("Data").Range("$b$3").Value

Dim width As Integer


width = Worksheets("Data").Range("$c$3").Value

With ActiveSheet
.Shapes.AddShape(msoShapeRectangle, 100, 100, length, width).Select
End With


End Sub


Sub drawactual()

Dim length As Integer


length = Worksheets("Data").Range("$b$4").Value

Dim width As Integer


width = Worksheets("Data").Range("$c$4").Value

With ActiveSheet
.Shapes.AddShape(msoShapeRectangle, 100, 100, length, width).Select
End With


End Sub

The coloring code(i should prob integrate the two, but need to learn how to :) ) and the macro to run all three at once

Sub Rated()
'
' Rated Macro
' Colors accordingly
'


'
Application.Run "'RECT2.xlsm'!ThisWorkbook.drawrated"
Selection.ShapeRange.ShapeStyle = msoShapeStylePreset10
End Sub
Sub Planned()
'
' Planned Macro
'


'
Application.Run "'RECT2.xlsm'!ThisWorkbook.drawplanned"
Selection.ShapeRange.ShapeStyle = msoShapeStylePreset15
End Sub


Sub Actual()
'
' Actual Macro
'


'
Application.Run "'RECT2.xlsm'!ThisWorkbook.drawactual"
Selection.ShapeRange.ShapeStyle = msoShapeStylePreset20
End Sub
Sub All()
'
' All Macro
' Runs all macros
'


'
Application.Run "'RECT2.xlsm'!Actual"
Application.Run "'RECT2.xlsm'!Planned"
Application.Run "'RECT2.xlsm'!Rated"
End Sub
 
Last edited:

Excel Facts

Get help while writing formula
Click the italics "fx" icon to the left of the formula bar to open the Functions Arguments dialog. Help is displayed for each argument.
ok i solved it myself - in the 2nd and 3rd rectangle, offset for the height was the diff between the width of the greater and lesser rectangles..

Now i have all 3 rectangles originating at the same left-bottom coordinates and swapping their order in the super macro has ensured they come in the correct order!!
 
Upvote 0

Forum statistics

Threads
1,214,918
Messages
6,122,249
Members
449,075
Latest member
staticfluids

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