Loop till both Solvers = zero

Flank

Board Regular
Joined
Dec 12, 2011
Messages
83
Hi all,

I am working on a model that after inputting multiple variables, I have to run solver on 1 field to equal zero then run solver on another field to equal zero and repeat this process until they are both zero.

Since they affect each other this can take multiple runs.

I have recorded a macro that is tied to a button so I just have to click back and fourth, but I would like to create a loop that will run them both until they both equal zero.
Code:
Sub CoolingWater()
'CoolingWater Macro
    SolverOk SetCell:="$B$54", MaxMinVal:=3, ValueOf:="0", ByChange:="$B$53"
    SolverSolve
End Sub

Sub RecycleAsh()
' RecycleAsh Macro

    SolverOk SetCell:="$C$41", MaxMinVal:=3, ValueOf:="0", ByChange:="$B$41"
    SolverSolve
End Sub
Can anyone help me get the loop written please?
 

Excel Facts

Why does 9 mean SUM in SUBTOTAL?
It is because Sum is the 9th alphabetically in Average, Count, CountA, Max, Min, Product, StDev.S, StDev.P, Sum, VAR.S, VAR.P.
I have adjusted my solver code a little so that it will close the prompt after arriving at a solution.

I also set cell F45= C41+B54

But I can't figure out how to write the Do Until loop.

I want it to call each of the routines until F45=0.01

Adjusted Code

Code:
Sub CoolingWater()
    Sheets("DFGD Inputs").Select
    SolverOk SetCell:="$B$54", MaxMinVal:=3, ValueOf:="0", ByChange:="$B$53"
    SolverSolve (True)
End Sub
Sub RecycleAsh()
    Sheets("DFGD Inputs").Select
    SolverOk SetCell:="$C$41", MaxMinVal:=3, ValueOf:="0", ByChange:="$B$41"
    SolverSolve (True)
End Sub
 
Upvote 0
Maybe ...
Code:
Sub SolveIt()
    Sheets("DFGD Inputs").Select
    SolverReset
 
    Do While Abs(Range("F45").Value - 0.01) > 0.0001
        CoolingWater
        RecycleAsh
    Loop
End Sub
 
Sub CoolingWater()
    SolverOk SetCell:="B54", MaxMinVal:=3, ValueOf:="0", ByChange:="B53"
    SolverSolve UserFinish:=True
End Sub
 
Sub RecycleAsh()
    SolverOk SetCell:="C41", MaxMinVal:=3, ValueOf:="0", ByChange:="B41"
    SolverSolve UserFinish:=True
End Sub
 
Upvote 0

Forum statistics

Threads
1,215,729
Messages
6,126,524
Members
449,316
Latest member
sravya

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top