Running Solver for multiple rows in worksheet

KyleO2

New Member
Joined
Apr 29, 2011
Messages
1
Hi,

I have created the following code to use solver when a cell is updated by a formula. It works fine.

Private Sub Worksheet_Calculate()
'Runs Macro when formula calculated
SolverReset
SolverOk SetCell:="$M$86", MaxMinVal:=1, ValueOf:=0, ByChange:="$N$86", Engine _
:=1, EngineDesc:="GRG Nonlinear"
SolverAdd CellRef:="$M$86", Relation:=2, FormulaText:="$G$86"
SolverOk SetCell:="$M$86", MaxMinVal:=1, ValueOf:=0, ByChange:="$N$86", Engine _
:=1, EngineDesc:="GRG Nonlinear"
SolverOk SetCell:="$M$86", MaxMinVal:=1, ValueOf:=0, ByChange:="$N$86", Engine _
:=1, EngineDesc:="GRG Nonlinear"
SolverSolve userFinish:=True

End Sub

Is there a way I can make the solver function do this for another 50 rows directly below row 86 detailed above?

The formulas and cells will be the same but just a row down.

Is there a way I can make the macros run only when the cell for that row is modified. I am worried it will be a slow running worksheet if it is fired up eveytime a calculation is made.

Thanks in advance
Kyle
 

Excel Facts

Excel Joke
Why can't spreadsheets drive cars? They crash too often!

Forum statistics

Threads
1,224,594
Messages
6,179,795
Members
452,943
Latest member
Newbie4296

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