+ Reply to Thread
Results 1 to 7 of 7

Sharing worksheets that use Solver

  1. #1
    Registered User
    Join Date
    09-20-2011
    Location
    Walnut Creek, CA
    MS-Off Ver
    Excel 2007
    Posts
    4

    Exclamation Sharing worksheets that use Solver

    I created a spreadsheet for work that uses a macro that runs the Solver add-in. I'd like to send this worksheet to other people for them to use, but they don't have Solver installed.

    The recipients are busy supervisors who don't have the time to learn how to install Solver.

    Does anyone have any advice? Is there a way for me to create a macro that performs the same function as Solver without actually requiring the tool to be installed?

    Thank you!

  2. #2
    Valued Forum Contributor tlafferty's Avatar
    Join Date
    04-08-2011
    Location
    United States, Tacoma, WA
    MS-Off Ver
    Excel 2010, Excel 2013 Customer Preview
    Posts
    1,112

    Re: Sharing worksheets that use Solver

    Add this code to the This Workbook object in the visual basic editor:
    Please Login or Register  to view this content.
    If your question has been satisfactorily addressed, please consider marking it solved. Click the Thread Tools dropdown and select Mark thread as solved.
    Also, you might want to add to the user's reputation by clicking the star icon in the lower left corner of the post with the answer- it's why we do what we do...

    Thomas Lafferty
    Analyst/Programmer

  3. #3
    Registered User
    Join Date
    09-20-2011
    Location
    Walnut Creek, CA
    MS-Off Ver
    Excel 2007
    Posts
    4

    Re: Sharing worksheets that use Solver

    Thanks Thomas. Will that automatically install Solver when they run the macro?

  4. #4
    Valued Forum Contributor tlafferty's Avatar
    Join Date
    04-08-2011
    Location
    United States, Tacoma, WA
    MS-Off Ver
    Excel 2010, Excel 2013 Customer Preview
    Posts
    1,112

    Re: Sharing worksheets that use Solver

    Yes - in fact, so long as macros are enabled, it will install it the first time they open the book without asking permission.

  5. #5
    Forum Expert Alf's Avatar
    Join Date
    03-13-2004
    Location
    Gothenburg/Mullsjoe, Sweden
    MS-Off Ver
    Excel 2019 and not sure I like it
    Posts
    4,758

    Re: Sharing worksheets that use Solver

    Just loading Solver using tlaffertys macro may not enough since

    I created a spreadsheet for work that uses a macro that runs the Solver add-in.
    You "clients" will probably get this message when they run your Solver macro: "Compile Error: Sub or Function not defined."

    Your "clients" must also set up a reference to the Solver add-in.

    Extract from Microsofts page on how to set up Solver:

    To use the Microsoft Excel Solver add-in functions in a VBA macro, you must reference the add-in from the VBA project of the workbook that contains the macros. If you do not reference the Microsoft Excel Solver add-in, you will receive the following compile error when you try to run the macro:
    Compile Error: Sub or Function not defined.
    To reference the Microsoft Excel Solver add-in for macros in your workbook, use the following steps:
    Open your workbook.
    On the Tools menu, point to Macro, and then click Visual Basic Editor.
    On the Tools menu, click References.
    In the Available References list, click to select the Solver.xls check box, and then click OK.

    Note If you do not see Solver.xls in the Available References list, click Browse. In the Add Reference dialog box, locate and select the Solver.xla file, and then click Open. The Solver.xla file is typically found in the C:\Program Files\Microsoft Office\Office\Library\Solver subfolder.
    You are now ready to use the Microsoft Excel Solver functions in a VBA macro.
    Alf

  6. #6
    Registered User
    Join Date
    09-20-2011
    Location
    Walnut Creek, CA
    MS-Off Ver
    Excel 2007
    Posts
    4

    Re: Sharing worksheets that use Solver

    Thanks Alf. I originally had to add a reference to Solver as well. That's exactly why I'm wondering if there is a way to avoid the requirement for Solver to be installed altogether.

    Is it possible to enter in some sort of VBA code that will accomplish the same task as Solver?

    Or can I run GoalSeek, but somehow use VBA to add a constraint?

  7. #7
    Forum Expert Alf's Avatar
    Join Date
    03-13-2004
    Location
    Gothenburg/Mullsjoe, Sweden
    MS-Off Ver
    Excel 2019 and not sure I like it
    Posts
    4,758

    Re: Sharing worksheets that use Solver

    First of all I think you should try tlaffertys macro + your macro on a PC where Solver has not been installed. Hopefully I’m wrong and everything will work fine.

    If you do get the “Compile Error: Sub or Function not defined” then perhaps tlaffertys macro could be expanded to include a VBA reference as well. I don’t know the appropriate VBA code to do that. Perhaps somebody else in the forum knows.

    To enter some VBA code that will accomplish the same task as Solver may be possible but you will have to upload a workbook showing what you wish to do.

    You can certainly run GoalSeek using VBA but as far as I know you can only achieve the target value by changing a single cell value and I don’t see how you can add constraint on that single cell.

    Still your problem is interesting and in this forum there are quite a number of wiser heads than mine so hopefully somebody has a better idea on how to solve your problem.

    Alf

+ 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