Public Function Intercept() As Double

Dim KnownY(1 To 5) As Double

Dim KnownX(1 To 5) As Double

Intercept = 0

KnownY(1) = 2

KnownY(2) = 3

KnownY(3) = 9

KnownY(4) = 1

KnownY(5) = 8

KnownX(1) = 6

KnownX(2) = 5

KnownX(3) = 11

KnownX(4) = 7

KnownX(5) = 5

Dim dAverageY As Double

Dim dAverageX As Double

Dim dSlope As Double

Dim dSlopeTop As Double

Dim dSlopeBottom As Double

dAverageY = 0

dAverageX = 0

dSlope = 0

For i = 1 To 5

dAverageY = dAverageY + KnownY(i)

dAverageX = dAverageX + KnownX(i)

Next i

dAverageY = dAverageY / 5

dAverageX = dAverageX / 5

For i = 1 To 5

dSlopeTop = dSlopeTop + ((dAverageX - KnownX(i)) * (dAverageY - KnownY(i)))

dSlopeBottom = dSlopeBottom + (dAverageX - KnownX(i)) ^ 2

Next i

dSlope = dSlopeTop / dSlopeBottom

For i = 1 To 5

Intercept = Intercept + KnownY(i) - dSlope * KnownX(i)

Next i

Intercept = Intercept / 5

End Function