环绕图表中的一个点

时间:2014-12-03 06:13:31

标签: excel geometry

我有一个(x,y)坐标,它将在散点图中绘制。我需要在绘制的点周围绘制一个半径为R的圆。

谢谢和问候, Prabhu.C

1 个答案:

答案 0 :(得分:0)

一个'裸骨'的例子可能会让你开始。您需要使用缩放,单位和定位等来满足您的背景。

这将绘制一个没有填充和红色圆周的圆圈,带有注释掉的线条以给它一个实心填充(更改。对于msoTrue可见。)

enter image description here

Sub drawCircle()
Dim ws As Worksheet
Dim cLeft As Long, cTop As Long
Dim cX As Long, cY As Long, cDia As Long
Dim c1 As Shape

Set ws = Sheets("Sheet1")
cX = Range("A2")
cY = Range("B2")
cDia = Range("C2").Value * 2

cLeft = cX - (cDia / 2)
cTop = cY - (cDia / 2)

    With ws
        Set c1 = .Shapes.AddShape(msoShapeOval, cLeft, cTop, cDia, cDia)
            With c1
                .Fill.Visible = msoFalse
                .Line.Weight = 2
                .Line.ForeColor.RGB = RGB(255, 0, 0)
                '.Fill.ForeColor.RGB = RGB(255, 0, 0)  'eg Red fill
            End With
    End With

End Sub