View Single Post
  #8   Report Post  
Posted to microsoft.public.excel.programming
BEETAL BEETAL is offline
external usenet poster
 
Posts: 30
Default VBA code to RUN Solver mutiple times (on different target cell

Dear DANA,

My salutation. The suggestion was " A Master's brilliant insight".

I am grateful to Jon and Dana.

Thanks again.
Now some explanation why I was so desperate to use Jon's code. Jon's code
elegantly tells me "how to use the constraints(I have tested it on one
constraint only and hope it can be used for tens and more constraints)".
Jon's few lines are pretty elegant. Now the last request as of today(sorry
again to be bothering you)

If anyone of you can advise me as to how to write the following constraint
code to incorporate more than one address for more than one constraint, I
shall be grateful(which already I am).

sByChange = Range("myrangetrial").Offset(iRow - 52, -3).Address

Do I have to create as many sBychange as the constraints or do I have to
create another loop like,
dim sbychange( ) as array
For k = 1 to 5
sByChange(1,K) = Range("myrangetrial").Offset(iRow - 52, -3 + k).Address
next k
Something like the above three will do or not! Please advice.

Thank you so much.

Regards

Siddh.
--
beetal


"Dana DeLouis" wrote:

Just to add for a Solver Loop.
You will keep adding Constraints in the loop.
The easiest way is to just Reset:

For r = 1 to 10
SolverReset ( brilliant insight)
SolverOk SetCell...etc


= = =
Dana DeLouis


BEETAL wrote:
Many thanks Jon for the time, yes, solver stops sometimes and I can see a
'First trial solution" comment on the left hand side.
Surprisingly,very annoying though, the following code works and it is no
where as elegant as yours. I just got it by hit-and-trial method.can we
modify this code and make it elegant like yours,this one works though

Worksheets("jon").Select
'For j = 1 To 10' to add for coloumns
For i = 1 To 8

SolverOk SetCell:=Range("myrangetrial").Offset(i - 1, 0).Address, _
MaxMinVal:=3, ValueOf:="0", ByChange:=Range("myrangetrial").Offset(i - 1,
-3).Address
SolverSolve True
Next i
next j ' for coloumns
end sub

I think I need to do the following

a) add one more for loop for more than one column - which I have tried to do

b) can I modify the models selection by solver,(conjugate gradient is what I
would prefer) - by VBA commands?

please advise. many thanks again.

P.S. - I am very upset that I wasted the whole day trying to run the elegant
version. I like that one. It is clear and makes sense. Why it stops half-way??