Create an Ellipse or Circle

scottpreece

New Member
Joined
Dec 7, 2016
Messages
3
If anyone could help..

I'm new to excel and VBA but wondered if anyone knew how I could produce a shape (Ellipse or Circle) given one X figure and one Y figure.

For example,

shapexy
134
268
31010
41420

<tbody>
</tbody>

I'm using Excel 2010.
Once this table has been filled in with X and Y figures, I would like to click a button that would produce the shape.
(Possibly one button to show 4 graphs at once) There will only ever be 4 shapes.

Thank you in advance
 

Excel Facts

Quick Sum
Select a range of cells. The total appears in bottom right of Excel screen. Right-click total to add Max, Min, Count, Average.
Where should these shapes go?
I just put the X, Y data in the range: B2:C5
and the shapes will be created next to these rows:
Code:
Sub CreateEllipseCircle()
Dim i As Long
With ActiveSheet
    For i = 2 To .Range("A" & .Rows.Count).End(xlUp).Row
        .Shapes.AddShape msoShapeOval, [B][COLOR=#ff0000].Range("D" & i).Left, .Range("D" & i).Top[/COLOR][/B], [B][COLOR=#0000ff].Range("B" & i).Value, .Range("C" & i).Value[/COLOR][/B]
    Next i
End With
End Sub
The ranges in red are the placement of the shapes.
The ranges in blue are the X, Y values from the sheet.
 
Upvote 0
Sub Macro13()
'
' Macro13 Macro
'


'
ActiveSheet.Shapes.AddShape(msoShapeOval, 10, 10, _
80, 80).Select
End Sub
 
Upvote 0
Where should these shapes go?
I just put the X, Y data in the range: B2:C5
and the shapes will be created next to these rows:
Code:
Sub CreateEllipseCircle()
Dim i As Long
With ActiveSheet
    For i = 2 To .Range("A" & .Rows.Count).End(xlUp).Row
        .Shapes.AddShape msoShapeOval, [B][COLOR=#ff0000].Range("D" & i).Left, .Range("D" & i).Top[/COLOR][/B], [B][COLOR=#0000ff].Range("B" & i).Value, .Range("C" & i).Value[/COLOR][/B]
    Next i
End With
End Sub
The ranges in red are the placement of the shapes.
The ranges in blue are the X, Y values from the sheet.


This has worked really well thank you! Is there any way of spacing the ovals so they do not overlap?
 
Upvote 0
Try this, just added variables to make it easier to "fiddle" with values:
Code:
Sub CreateEllipseCircle()
Dim i As Long, LeftPlacement As Long, TopPlacement As Long, xWidth As Long, yHeight As Long, ySpacing As Long
ySpacing = 5
With ActiveSheet
    TopPlacement = .Range("D2").Top
    For i = 2 To .Range("A" & .Rows.Count).End(xlUp).Row
        xWidth = .Range("B" & i).Value
        yHeight = .Range("C" & i).Value
        LeftPlacement = .Range("D" & i).Left
        .Shapes.AddShape msoShapeOval, LeftPlacement, TopPlacement, xWidth, yHeight
        TopPlacement = TopPlacement + yHeight + ySpacing
    Next i
End With
End Sub
 
Upvote 0

Forum statistics

Threads
1,214,827
Messages
6,121,812
Members
449,048
Latest member
greyangel23

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