Goal Seek and Solver VBA Scripts Examples

Solver Script:
(Make sure Solver is function is Enable in your Excel)

SolverReset
SolverOptions precision:=0.000001
SolverOk SetCell:=Range("A1"), MaxMinVal:=3, ValueOf:=Range("B1").Value, ByChange:=Range("C1")
SolverSolve UserFinish:=True
SolverFinish KeepFinal:=1
* Note: All target cells need to be on the same sheet for the solver function to run.

GoalSeek:

Range("A1").GoalSeek Goal:=Range("B1"), ChangingCell:=Range("C1")
* Note: Target cells can be on different sheets