Skip to main content

SolverSave Function

Table of contents
  1. Syntax
  2. Example

Saves the Solver problem specifications on the worksheet.


SolverSave( SaveArea)

SaveArea Required Variant. The range of cells where the Solver model is to be saved. If this is a single-cell range, Solver uses as many cells as it needs to save the model, in a column starting with the specified cell. If this is a multi-cell range, Solver uses only cells within that range, even if the model cannot be entirely saved, The range represented by the SaveArea argument can be on any worksheet, but you must specify the worksheet if it is not the active sheet. For example, SolverSave("Sheet2!A1:A3") saves the model on Sheet2 even if Sheet2 is not the active sheet.


The SolverSave function saves the current problem to a range on the active worksheet.

Sub SolverDemo()
    Range("F4").Formula = "=SUM(C4:E4)"
    Range("F5").Formula = "=SUM(C5:E5)"
    Range("F6").Formula = "=SUM(C6:E6)"
    Range("F7").Formula = "=SUM(F4:F6)"
    SolverOptions Precision:=0.001
    SolverOK SetCell:=Range("F7"), MaxMinVal:=3, ValueOf:=50, ByChange:=Range("C4:E6")
    SolverAdd CellRef:=Range("F4:F6"), Relation:=1, FormulaText:=100
    SolverAdd CellRef:=Range("C4:E6"), Relation:=3, FormulaText:=0
    SolverAdd CellRef:=Range("C4:E6"), Relation:=4
    SolverSolve UserFinish:=False
    SolverSave SaveArea:=Range("A33")
End Sub

Leave a comment

Your email address will not be published. Required fields are marked *

Format your code: <pre><code class="language-vba">place your code here</code></pre>