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

Réponses

Toutes les réponses

  • Hi,

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

    • Proposé comme réponse ryguy72 samedi 9 août 2014 14:28
    • Marqué comme réponse danishaniModerator mardi 16 septembre 2014 05:30
    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
  • Thanks, very helpful.

    I have just started learning macro and this was something i was looking for.

    jeudi 7 août 2014 16:49