none
Sub or Function not defined

    Question

  • I came accross a strange problem. I tried to record a macro where I used Solver.

    After I tried to run it, I was given an error message:

     

    Compile Error:

    Sub or Function not defined.

     

    The function where VBA stops is "SolverOK".

    It is not a macro that I coded, I recorded it in the excell sheet.

     

    Thanks for any advice.

    Lubomir

     

     

    --------------------------------------------------------------------------

    Code that was generated is obviously correct:

     

    Sub solver()
    ' solver Macro
    ' Macro recorded 26/07/2007 by Z05041K
        SolverOk SetCell:="$B$115", MaxMinVal:=3, ValueOf:="0", ByChange:="$B$91"
        SolverSolve
    End Sub

    jeudi 26 juillet 2007 09:27

Toutes les réponses

  • Hi,

    You need to include a reference to SOLVER.XLA
    With VBE use menu Tools > References. Check the Solver reference.

    jeudi 26 juillet 2007 18:10
  • I have the same problem.

     

    OK, found this in VB Help

     

    SolverOk Function

     

    Defines a basic Solver model. Equivalent to clicking Solver on the Tools menu and then specifying options in the Solver Parameters dialog box.

    Before you use this function, you must establish a reference to the Solver add-in. With a Visual Basic module active, click References on the Tools menu, and then select the Solver.xla check box under Available References. If Solver.xla doesn't appear under Available References, click Browse and open Solver.xla in the \Office\Library\Solver\ subfolder.

     

    The problem is when I click Tools on the menu bar, "references" is greyed out. Went back and made sure I had all the Office modules installed and still can't get to references.

     

    What now???

    samedi 14 juin 2008 01:52
  • make sure u hit the stop button b4 u go into tools and references.

    if the error is highlighted, the references part will be greyed out...

     

    • Proposé comme réponse Roger Moore mercredi 22 février 2012 18:02
    samedi 14 juin 2008 07:05
  • Thank you very much. That fixed the problem.

     

    lundi 16 juin 2008 18:10
  • Thanks so much. Very Helpful!!
    mercredi 11 mai 2011 02:15