Hi,
I'm trying to write a macro that makes solver loop through a range of columns.
The idea is that it starts off by maximising cell b8 by changing b2:b4. After having solved that problem, I need solver to do the exact same thing but now by maximising cell c3 by changing c2:c4... and so on.
I have a range of 100 columns for which this has to be done so a macro sounds like a good solution.
The only problem is that I'm not really skilled in VBA yet. I hope you can help. This is de code I have so far, until now it only solves the problem for b8 by changing b2:b4 but it doesn't continue to the next column. Any help is appreciated.
Sub Solve()
'
' Solve Macro
For i = 1 To 100
ml = Range("b8").Offset(rowoffset = 0, columnoffset = i)
es = Range("b2:b4").Offset(rowoffset = 0, columnoffset = i)
SolverOk SetCell:=ml, MaxMinVal:=1, ValueOf:=0, ByChange:=es, _
Engine:=1, EngineDesc:="GRG Nonlinear"
SolverSolve (True)
Next i
End Sub
That's it. Thank you for looking at the code.
Cheers,
Bastiaan
Bookmarks