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

Hi. Are there any ideas here you can use?
Your description of the problem is not very clear to me.
If Column F is related to Column C. Is Column G related to D?
If not, then if F is zero because C is set to the correct value, what
happens when G is zero and a different value is in C? (F won't be zero
anymore!)
This small demo limits the changing cell in Column C to 0-100.

Sub Demo()
Dim R As Long
Dim Result As Long
For R = 3 To 20
SolverReset
SolverOk Cells(R, 6), 3, 0, Cells(R, 3)
SolverAdd Cells(R, 3), 3, 0 '= 0
SolverAdd Cells(R, 3), 1, 100 '<= 100
Result = SolverSolve(True)
If Result = 3 Then
'Error: Did not converge to a soluion
Debug.Print "No solution in Row: "; R
End If
Next R
End Sub


I would be guessing, but it sounds like your matrix, and your "Changing
Cells" need to be the same size, and square in size, to do a "conjugate
gradient" Six Columns, by 250 rows, sounds like you have too many
equations, and too few variables.

'= = =
'HTH :)
Dana DeLouis



BEETAL wrote:
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.