使用規劃求解 VBA 函數Using the Solver VBA Functions

必須先啟用 [Excel 選項]**** 對話方塊中的規劃求解增益集,才可以開始使用 VBA 的規劃求解 VBA 函數。Before you can use the Solver VBA functions from VBA, you must enable the Solver add-in in the Excel Options dialog box.

  1. 按一下 [檔案]**** 索引標籤,然後按一下 [Excel]**** 索引標籤下的 [選項]****。Click the File tab, and then click Options below the Excel tab.

  2. 按一下 [Excel 選項]**** 對話方塊中的 [增益集]****。In the Excel Options dialog box, click Add-Ins.

  3. 選取 [管理]**** 下拉式方塊中的 [Excel 增益集]****,然後按一下 [開始]****。In the Manage drop-down box, select Excel Add-ins, and then click Go.

  4. 選取 [增益集]**** 對話方塊中的 [規劃求解增益集]****,然後按一下 [確定]。In the Add-Ins dialog box, select Solver Add-in, and then click OK.

在您啟用規劃求解增益集之後,如果尚未安裝該增益集,Excel 會自動安裝,而 [規劃求解]**** 命令會新增至功能區 [資料]**** 索引標籤上的 [分析]**** 群組中。After you have enabled the Solver add-in, Excel will auto-install the Add-in if it is not already installed, and the Solver command will be added to the Analysis group on the Data tab in the ribbon.

在您可以於 Visual Basic 編輯器中使用規劃求解 VBA 函數之前,您必須建立規劃求解增益集的參考。Before you can use the Solver VBA functions in the Visual Basic Editor, you must establish a reference to the Solver add-in. 在模組作用中的 Visual Basic 編輯器中,按一下 [工具]**** 功能表上的 [參照]****,然後選取 [可用參照]**** 下的 [規劃求解]****。In the Visual Basic Editor, with a module active, click References on the Tools menu, and then select Solver under Available References. 如果規劃求解未出現在可用參照中,請按一下瀏覽,然後在 \Program Files\Microsoft Office\Office14\Library\SOLVER 子資料夾中開啟 Solver.xlam。If Solver does not appear under Available References, click Browse, and then open Solver.xlam in the \Program Files\Microsoft Office\Office14\Library\SOLVER subfolder. 下列函數可用來控制來自 VBA 的規劃求解增益集。The following functions can be used to control the Solver add-in from VBA. 每個函數會與您透過規劃求解增益集的 [規劃求解參數]****、[規劃求解選項]**** 和 [規劃求解結果]**** 對話方塊互動式執行的動作對應。Each function corresponds to an action that you can perform interactively, through the Solver Parameters, Solver Options, and Solver Results dialog boxes of the Solver add-in.

支援和意見反應Support and feedback

有關於 Office VBA 或這份文件的問題或意見反應嗎?Have questions or feedback about Office VBA or this documentation? 如需取得支援服務並提供意見反應的相關指導,請參閱 Office VBA 支援與意見反應Please see Office VBA support and feedback for guidance about the ways you can receive support and provide feedback.