Solver stuck on solution

becca85

New Member
Joined
Mar 31, 2011
Messages
2
Hi, I'm running solver within a macro which runs the solver multiple times, changing one variable each time and pasting the results into another worksheet. Unfortunately the solver seems to get stuck on a solution and makes the same allocation decision each time. The code for the solver part is below. There is a minimum allocation to one enterprise which a collegue suggested I incorporate by changing the starting points using the 'npoints' code. If you need more information please let me know, I just didn't want to post all the extra code and the workbook if not needed because it's a large file.

Dim npoints As Single
Dim icol As Integer

npoints = Worksheets("Euc OptN").Cells(62, 2).Value
icol = 2
For i = 1 To npoints
ActiveSheet.Range(Cells(60, icol), Cells(61, icol)).Select
Selection.Copy
Range("B55").Select
ActiveSheet.Paste

SolverOk SetCell:="$B$45", MaxMinVal:=1, ValueOf:="0", ByChange:= _
"$B55:$B$56"
SolverOptions AssumeLinear:=False, AssumeNonNeg:=True
SolverSolve UserFinish:=True

Range("B45").Select
Selection.Copy
ActiveSheet.Cells(64, icol).Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False

icol = icol + 1
Next i

Thanks.
 

Excel Facts

When did Power Query debut in Excel?
Although it was an add-in in Excel 2010 & Excel 2013, Power Query became a part of Excel in 2016, in Data, Get & Transform Data.

Forum statistics

Threads
1,224,524
Messages
6,179,310
Members
452,906
Latest member
phanmemchatdakenhupviral

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