Sub kouten_senbun(x1, y1, x2, y2, x3, y3, x4, y4, x, y)
'============================
' 2点 (x1, y1)、(x2, y2)を通る線分Aと
' 2点 (x3, y3)、(x4, y4)を通る線分Bの交点(x,y)を求めます。
'===============================
Dim x1s As Single, y1s As Single
Dim x1e As Single, y1e As Single
Dim x2s As Single, y2s As Single
Dim x2e As Single, y2e As Single
x1s = x1
y1s = y1
x1e = x2
y1e = y2
x2s = x3
y2s = y3
x2e = x4
y2e = y4
a1 = (y1e - y1s) / (x1e - x1s)
a2 = y1s - x1s * a1
b1 = (y2e - y2s) / (x2e - x2s)
b2 = y2s - x2s * b1
x = (b2 - a2) / (a1 - b1)
y = a1 * x + a2
ActiveSheet.Shapes.AddShape(msoShapeOval, x, y, Dot, Dot).Select
End Sub