Sub МНК()
Const n = 10
Dim x(1 To n) As Double, y(1 To n) As Double, i As Integer, a As Double, b As Double, yi As Double
For i = 1 To n
x(i) = Cells(i, 1)
y(i) = Cells(i, 2)
Next i
Линейная x, y, n, a, b
For i = 1 To n
yi = a * x(i) + b
Cells(i, 3) = yi
Next i
Debug.Print a, b
End Sub

Sub Линейная (x() As Double, y() As Double, n As Integer, a As Double, b As Double)
Dim Sx As Double, Sy As Double, Sxy As Double, Sx2 As Double, i As Integer
For i = 1 To n
Sx = Sx + x(i)
Sy = Sy + y(i)
Sxy = Sxy + x(i) * y(i)
Sx2 = Sx2 + x(i) * x(i)
Next i
b = n * Sx2 - Sx ^ 2
a = (n * Sxy - Sx * Sy) / b
b = (Sy * Sx2 - Sx * Sxy) / b
End Sub