ich habe aus Spaß einen kleinen Code geschrieben, welcher
einen Kreis in Excel "zeichnet".
Mein Problem liegt aber, einen Sinnvollen Startpunkt zu setzten für die x- und y-Achse.
Habt ihr eine Idee wie man die Startpunkte sinnvoll ermitteln könnte?
Hier der Code(es geht um startX u. startY):
Option Explicit
Private Sub CellToDraw(ByVal radius As Integer)
Dim y0 As Integer, y1 As Integer
Dim x As Integer, y As Integer
Dim startX As Integer, startY As Integer
startX = radius * 2: startY = radius * 2
For x = (radius * -1) To radius
y1 = Sqr(radius * radius - x * x)
For y = y0 To y1
Cells(x + startX, y + startY).Interior.ColorIndex = 4
Cells(x + startX, y * -1 + startY).Interior.ColorIndex = 4
Cells(x * -1 + startY, y + startY).Interior.ColorIndex = 4
Cells(x * -1 + startX, y * -1 + startY).Interior.ColorIndex = 4
Next y
y0 = y1
Next x
End Sub
Sub MyCircle()
Dim radius As Integer
radius = Application.InputBox("Bitte geben Sie den Radius als Ganzzahl ein", "Kreis in _
Excel", Type:=1)
CellToDraw (radius)
End Sub