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.
Bookmarks