Plot my auto-shapes on a userform

bugatti79

Board Regular
Joined
Feb 18, 2012
Messages
70
Folks,

I have created lines and circles using auto shapes and these are placed on a worksheet. The auto-shapes are modifed based on user inputs.

It is working perfectly. All I want to do now is put it on a user form. Any ideas? Below is the code for plotting the shapes
Would an idea to make a picture out of it and copy onto the userform?

Code:
Public Sub Plot_Circles()

Dim line1_Beginx As Single, line1_beginy As Single, line1_endx As Single, line1_endy As Single
Dim line2_Beginx As Single, line2_beginy As Single, line2_endx As Single, line2_endy As Single
Dim line3_Beginx As Single, line3_beginy As Single, line3_endx As Single, line3_endy As Single
Dim CD_2 As Single, CD_1 As Single, Theta_c As Single, R_3 As Single, R_2 As Single, R_1 As Single




'Clear Sheets
'Sheet1.Shapes.SelectAll
'Selection.Delete


Range("Q2").Select
ActiveCell.FormulaR1C1 = "=VLOOKUP(RC[-10],R[2]C[-16]:R[98]C[-2],9,TRUE)"
Range("r2").Select
ActiveCell.FormulaR1C1 = "=VLOOKUP(RC[-11],R[2]C[-17]:R[98]C[-3],10,TRUE)"
Range("s2").Select
ActiveCell.FormulaR1C1 = "=VLOOKUP(RC[-12],R[2]C[-18]:R[98]C[-4],11,TRUE)"
Range("t2").Select
ActiveCell.FormulaR1C1 = "=VLOOKUP(RC[-13],R[2]C[-19]:R[98]C[-5],4,TRUE)"
Range("u2").Select
ActiveCell.FormulaR1C1 = "=VLOOKUP(RC[-14],R[2]C[-20]:R[98]C[-6],3,TRUE)"
Range("v2").Select
ActiveCell.FormulaR1C1 = "=VLOOKUP(RC[-15],R[2]C[-21]:R[98]C[-7],2,TRUE)"


CD_2 = Cells(2, 18)
CD_1 = Cells(2, 17)
Theta_c = Cells(2, 19)
R_3 = Cells(2, 20)
R_2 = Cells(2, 21)
R_1 = Cells(2, 22)






'Calculate positions of line vertices for plots
            
            line1_Beginx = 1000
            line1_beginy = 1000
            line1_endx = 1000 + CD_2
            line1_endy = 1000
            line2_Beginx = line1_endx - CD_1 * Sin(3.141 * (90 - Theta_c) / 180)
            line2_beginy = 1000 - CD_1 * Cos(3.141 * (90 - Theta_c) / 180)
            line2_endx = line1_endx
            line2_endy = line1_endy
            line3_Beginx = line1_Beginx
            line3_beginy = line1_beginy
            line3_endx = line2_Beginx
            line3_endy = line2_beginy
            
'Plot Gear Train
Sheets("Sheet1").Select
ActiveSheet.Shapes.AddLine(line1_Beginx, line1_beginy, line1_endx, line1_endy).Select
ActiveSheet.Shapes.AddLine(line2_Beginx, line2_beginy, line2_endx, line2_endy).Select
ActiveSheet.Shapes.AddLine(line3_Beginx, line3_beginy, line3_endx, line3_endy).Select
ActiveSheet.Shapes.AddShape(msoShapeOval, 20, 20, 20, 20).Select
With Selection
    .ShapeRange.Fill.Transparency = 1#
    .Height = 2 * R_3
    .Left = 1000 - .Height / 2
    .Width = 2 * R_3
    .Top = 1000 - .Width / 2
 End With
'R/Cirle
 ActiveSheet.Shapes.AddShape(msoShapeOval, 20, 20, 20, 20).Select
With Selection
    .ShapeRange.Fill.Transparency = 1#
    .Height = 2 * R_2
    .Left = (1000 + CD_2) - .Height / 2
    .Width = 2 * R_2
    .Top = 1000 - .Width / 2
 End With
'Top Circle
 ActiveSheet.Shapes.AddShape(msoShapeOval, 20, 20, 20, 20).Select
With Selection
    .ShapeRange.Fill.Transparency = 1#
    .Height = 2 * R_1
    .Left = (1000 + CD_2 - CD_1 * Sin(3.141 * (90 - Theta_c) / 180)) - .Height / 2
    .Width = 2 * R_1
    .Top = (1000 - CD_1 * Cos(3.141 * (90 - Theta_c) / 180)) - .Width / 2
 End With


End Sub
 

Excel Facts

How to find 2nd largest value in a column?
MAX finds the largest value. =LARGE(A:A,2) will find the second largest. =SMALL(A:A,3) will find the third smallest

Forum statistics

Threads
1,203,453
Messages
6,055,530
Members
444,794
Latest member
HSAL

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