SolverFinish 函數SolverFinish Function

指示 Microsoft Office Excel 當解決方案程序完成時,如何處理結果及建立何種報表。Tells Microsoft Office Excel what to do with the results and what kind of report to create when the solution process is completed.

注意事項 根據預設,規劃求解增益集並未啟用。Note The Solver add-in is not enabled by default. 使用本函數之前,必須先安裝並啟用規劃求解增益集。Before you can use this function, you must have the Solver add-in enabled and installed. 如需如何安裝並啟用規劃求解增益集的詳細資訊,請參閱 使用規劃求解 VBA 函數For information about how to do that, see Using the Solver VBA Functions. 安裝規劃求解增益集之後,必須建立對規劃求解增益集的參照。After the Solver add-in is installed, 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.

SolverFinishKeepFinalReportArrayOutlineReportsSolverFinish(KeepFinal, ReportArray, OutlineReports)

KeepFinal選用的VariantKeepFinal Optional Variant. 可以是 1 或 2。Can be either 1 or 2. 如果**KeepFinal** 為1或省略,則會將最終的求解值保留在變數儲存格中,取代任何先前的值。If KeepFinal is 1 or omitted, the final solution values are kept in the changing cells, replacing any former values. 如果**KeepFinal** 是2,則會丟棄最後的解決方案值,而且會還原先前的值。If KeepFinal is 2, the final solution values are discarded, and the former values are restored. ReportArray選用的VariantReportArray Optional Variant. 規劃求解完成時,Excel 會建立的報告類型:The kind of report that Excel will create when Solver is finished:

  • 如果使用 Simplex LP 或 GRG Nonlinear Solving 方法,1 會建立運算結果報表,2 會建立敏感度報表,而 3 會建立極限值報表。When the Simplex LP or GRG Nonlinear Solving method is used, 1 creates an Answer report, 2 creates a Sensitivity report, and 3 creates a Limit report.

  • 如果使用 Evolutionary Solving 方法,1 會建立運算結果報表,而 2 會建立母體報表。When the Evolutionary Solving method is used, 1 creates an Answer report, and 2 creates a Population report.

  • 當**SolverSolve** 傳回5時(規劃求解找不到可行的方案),1會建立可行性報告,而2會建立可行性界限報告。When SolverSolve returns 5 (Solver could not find a feasible solution), 1 creates a Feasibility Report, and 2 creates a Feasibility-Bounds report.

  • 如果 SolverSolve 傳回 7 (未滿足線性條件),1 會建立線性報表。When SolverSolve returns 7 (the linearity conditions are not satisfied), 1 creates a Linearity report.

您可以使用Array函數來指定您想要顯示的報表,例如ReportArray:= Array(1,3)Use the Array function to specify the reports you want to display — for example, ReportArray:= Array(1,3). OutlineReports選用的VariantOutlineReports Optional Variant. 可以是TrueFalseCan be either True or False. 如果**OutlineReports** 是False或省略,則會以「一般」格式產生報告,而不會顯示大綱。If OutlineReports is False or omitted, reports are produced in the "regular" format, without outlining. 如果**OutlineReports** 為True,則報告會產生與您為決策變數和限制所輸入之儲存格範圍相對應的分級顯示群組。If OutlineReports is True, reports are produced with outlined groups corresponding to the cell ranges you've entered for decision variables and constraints.

範例Example

此範例載入先前計算過的求解模式 (該模式儲存於 Sheet1 中),再次求解該模式,然後在新工作表上產生答案報告。This example loads the previously calculated Solver model stored on Sheet1, solves the model again, and then generates an answer report on a new worksheet.

Worksheets("Sheet1").Activate 
SolverLoad LoadArea:=Range("A33:A38") 
SolverSolve UserFinish:=True 
SolverFinish KeepFinal:=1, ReportArray:=Array(1)

支援和意見反應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.