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

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: