+ Reply to Thread
Results 1 to 5 of 5

Compile error: Sub or Function not defined ("SolverOk")

  1. #1
    Registered User
    Join Date
    12-23-2011
    Location
    Arizona, USA
    MS-Off Ver
    Excel 2003
    Posts
    9

    Question Compile error: Sub or Function not defined ("SolverOk")

    I recorded a macro and then tried to run it.
    The macro includes repeated use of the Solver Tool, to save me some time.
    Excel does not recognize the "SolverOk" nomenclature (it's highlighted in gray).
    I tried checking my References in the VBA editor, but "References" is grayed out so I can't even get into it.


    Please Login or Register  to view this content.
    Last edited by jimmypants; 12-23-2011 at 03:52 PM. Reason: sorry, I'm a newbie - trying to comply to forum rules...

  2. #2
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Compile error: Sub or Function not defined ("SolverOk")

    You have to set a reference to Solver to use it in VBA, as you've figured out.

    The way to do it manually is ...

    In the VBE, Tools > References, paste this in the File name box:
    C:\Program Files\Microsoft Office\OFFICExx\Library\SOLVER

    … after replacing xx with your version of Excel (e.g., 11 for Excel 2003, 12 for Excel 2007).

    Change the file type dropdown to *.xls, *.xla, and pick SOLVER.XLA

    You can't set a reference when code execution is suspended, so press the reset button (or do Tools > Reset), and then try.
    Entia non sunt multiplicanda sine necessitate

  3. #3
    Registered User
    Join Date
    12-23-2011
    Location
    Arizona, USA
    MS-Off Ver
    Excel 2003
    Posts
    9

    Cool Re: Compile error: Sub or Function not defined ("SolverOk")

    shg,
    Thank you so much for replying quickly !
    Great news: I did not have to do the protocol which you graciously provided.

    Here is what I did:
    1) I don't know if this had any effect or not, but... In my own searching for a solution this morning (before receiving a reply), I had gone into another section of the Tools menu in an attempt to see if there was any way for me to activate the References section. I can't remember for sure, but I think I went into the "Additional Controls" menu. I selected something like "MS Office". The References choice still did not change from its grayed-out state, nor did the macro work.
    2) I had to leave the house for a couple hours, so I closed the Excel file. When I got back, I saw your reply and began to follow the directions. However, upon opening the file and going to the VBA Editor Tools menu, I noticed that the word "References" was no longer grayed-out! I proceeded to go into the References section and check the "Solver" box.
    3) I attempted to run the Macro, and it worked!

    You mentioned: "You can't set a reference when code execution is suspended, so press the reset button (or do Tools > Reset), and then try." I wonder if this was the reason why the "References" was grayed-out. I don't know. Anyway...

    I think my problem is now solved.

    The only unfortunate thing is that I have to press "Ok" to accept every Solver solution. I might have to post a new trouble thread to figure out how to accept all answers. The good thing is that Solver will never have any problems/errors with the particular formulae I am telling it to solve.

    Thank you again for the quick reply!

  4. #4
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Compile error: Sub or Function not defined ("SolverOk")

    The only unfortunate thing is that I have to press "Ok" to accept every Solver solution.
    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    12-23-2011
    Location
    Arizona, USA
    MS-Off Ver
    Excel 2003
    Posts
    9

    Re: Compile error: Sub or Function not defined ("SolverOk")

    Thanks, shg!
    I actually figured it out on my own, after I was able to figure out how to install the "Help" feature. I think it's ridiculous that it has to be installed manually because newbies (like me) can't be expected to figure out how to install anything, let alone the freaking Help feature!

    Here is the thread I posted regarding "UserFinish:=True"...

    http://www.excelforum.com/excel-prog...uccessful.html

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1