VBA code for running a Solver model multiple times where 'by changing cells' are changing!

kkaass

Board Regular
Joined
May 8, 2015
Messages
54
Hi,

I am a bit lost with my Solver model. Actually I want to re-run my 'Solver' model multiple times with VBA, but with one small change. I would like the 'changing cells' to keep changing every time I re-run the model.

So basically my target cell is: $O$3
I want to maximize it
Changing cells are: $O$3 and $H$2:$H$11
Constraints are:
$K$4:$K$5 <= $M$4:$M$5 and
$K$6:$K$7>= $M$6:$M$7

I know that the dollar signs are there to fix the values. But what I really want is a VBA code where the changing cells '$H$2:$H$11' keep on changing.

For instance, first a VBA code runs where changing cells are '$H$2:$H$11'

Then some changes are made in the worksheet (avoiding too many details) such that the changing are '$H$2:$H$12'

Then the VBA code for Solver is re-run

Then again additional values are added in some cells and now the changing cells are '$H$2:$H$13'

Now the VBA code for Solver is re-run again and so on.

So basically starting from H2, the last cell for that H column is incremented by 1 and then the VBA code re-runs.

Nothing else changes in the model (like constraints) because they are set up in that way already. But I don't know how to do that with changing cells for column H only.

Any help will be greatly appreciated! Thanks in advance!
 

Excel Facts

Ambidextrous Undo
Undo last command with Ctrl+Z or Alt+Backspace. If you use the Undo icon in the QAT, open the drop-down arrow to undo up to 100 steps.

Forum statistics

Threads
1,215,511
Messages
6,125,250
Members
449,218
Latest member
daynle

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