title: Use of solver to minimise an vba function (instead of an excel cell wrt other excel cell)
body: <p>I want to minimise the function myFunction by changing the values of alpha. In this dummy example, I expect alpha = X (= 3).</p>
  
  <p>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. </p>
  
  <p>Thus I wonder <strong>how to write correctly the Minimizer function - Solver part</strong>. (the rest being correct).</p>
  
  <pre><code>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
  </code></pre>