title: Macro Excel: To insert a circle into specific range in cell
body: <p>I have a circle that has a fixed diameter and center. What I need to do now is to insert the circle into the given range. Eg, given 11 boxes of column and 10 boxes of rows to be inserted in excel cell. After entering the given range, the circle will be within the selected range with its fixed center but the boxes would have different measurement for its height and width. My question is how do I insert the circle into any given range (as in 11 x 10 or 9 x 12) with different height and width of the cells?</p>
  
  <p>My code:</p>
  
  <pre><code>Sub DrawCircleWithCenter()
  Dim cellwidth As Single
  Dim cellheight As Single
  Dim ws As Worksheet
  Dim rng As Range
  Dim Shp2 As Shape
  
  
  CellLeft = Selection.Left
  CellTop = Selection.Top
  
  ActiveSheet.Shapes.AddShape(msoShapeOval, CellLeft, CellTop, 565 / 2, 565 / 2).Select
  Selection.ShapeRange.Fill.Visible = msoFalse
  With Selection.ShapeRange.Line
      .Visible = msoTrue
      .ForeColor.RGB = RGB(0, 0, 0)
      .Transparency = 0
  End With
  
  i = 182
  Set Shp2 = ActiveSheet.Shapes.AddShape(i, CellLeft, CellTop, 20, 20)
  Shp2.ShapeStyle = msoShapeStylePreset1
  Set rng = ActiveWindow.VisibleRange
  
  Selection.Left = rng.Width / 2 - Selection.Width / 2
  Selection.Top = rng.Height / 2 - Selection.Height / 2
  Shp2.Left = rng.Width / 2 - Shp2.Width / 2
  Shp2.Top = rng.Height / 2 - Shp2.Height / 2
  
  
  End Sub
  </code></pre>