Sub PS() Dim x1 As Double, y1 As Double, x2 As Double, y2 As Double Dim x3 As Double, y3 As Double x1 = Cells(2, 2): y1 = Cells(2, 3) x2 = Cells(3, 2): y2 = Cells(3, 3) x3 = Cells(4, 2): y3 = Cells(4, 3) a = L(x1, y1, x2, y2) b = L(x2, y2, x3, y3) c = L(x3, y3, x1, y1) P = a + b + c Cells(6, 2) = P p2 = P / 2 S = Sqr(p2 * (P - a) * (P - b) * (P - c)) Cells(7, 2) = S End Sub
Function L(x1 As Double, y1 As Double, x2 As Double, y2 As Double) As Double L = Sqr((x2 - x1) ^ 2 + (y2 - y1) ^ 2) End Function
Dim x1 As Double, y1 As Double, x2 As Double, y2 As Double
Dim x3 As Double, y3 As Double
x1 = Cells(2, 2): y1 = Cells(2, 3)
x2 = Cells(3, 2): y2 = Cells(3, 3)
x3 = Cells(4, 2): y3 = Cells(4, 3)
a = L(x1, y1, x2, y2)
b = L(x2, y2, x3, y3)
c = L(x3, y3, x1, y1)
P = a + b + c
Cells(6, 2) = P
p2 = P / 2
S = Sqr(p2 * (P - a) * (P - b) * (P - c))
Cells(7, 2) = S
End Sub
Function L(x1 As Double, y1 As Double, x2 As Double, y2 As Double) As Double
L = Sqr((x2 - x1) ^ 2 + (y2 - y1) ^ 2)
End Function