# Create an Ellipse or Circle

#### scottpreece

##### New Member
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,

 shape x y 1 3 4 2 6 8 3 10 10 4 14 20

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

### Excel Facts

What is =ROMAN(40) in Excel?
The Roman numeral for 40 is XL. Bill "MrExcel" Jelen's 40th book was called MrExcel XL.

#### BQardi

##### Active Member
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.

Sub Macro13()
'
' Macro13 Macro
'

'
80, 80).Select
End Sub

#### scottpreece

##### New Member
Thank you, I'll attempt this now..

I'm trying to get the shapes on a seperate xy graph sheet if possible

#### scottpreece

##### New Member
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?

#### BQardi

##### Active Member
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``````

Replies
1
Views
347
Replies
0
Views
94
Replies
2
Views
134
Replies
5
Views
177
Replies
0
Views
42

1,191,228
Messages
5,985,405
Members
439,962
Latest member
max_york

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

### Which adblocker are you using?

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

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