I want to minimise the function myFunction by changing the values of alpha. In this dummy example, I expect alpha = X (= 3).
To do so, I want to use the Excel Solver, and avoid copying part of the code in the sheet. This code is part of a Least Sqare Interpolator.
Thus I wonder how to write correctly the Minimizer function - Solver part. (the rest being correct).
Option Explicit
Private alpha As Double
Function myFunction(X)
'myFunction , the variable is alpha
myFunction = ( alpha - X ) ^2
End Function
Public Sub Minimizer()
Dim X As Double
X = 3
Solver (change alpha with the value that minimize myFunction(X))
End Sub