0

I have a very short question, but I simply dont get why this isnt working.

I have a solver constraint set up. The following code is working (row 14 is going to be the changeable variables, while row 13 will be the constraints).

SolverAdd CellRef:=ws1.Range(ws1.Cells(14, 2), ws1.Cells(14, 5)), Relation:=1, FormulaText:="$B$13:$E$13"

So I thought that following should be working as well

SolverAdd CellRef:=ws1.Range(ws1.Cells(14, 2), ws1.Cells(14, 5)), Relation:=1, FormulaText:=ws1.Range(ws1.Cells(13, 2), ws1.Cells(13, 5))

And I am sitting here, scratching my head and wondering why I get an error (undefined internal error or too less usable ram).

1 Answer 1

1

FormulaText is expecting a string - so if you add 'Address' to the end of the range it should work:

SolverAdd CellRef:=ws1.Range(ws1.Cells(14, 2), ws1.Cells(14, 5)), Relation:=1, FormulaText:=ws1.Range(ws1.Cells(13, 2), ws1.Cells(13, 5)).Address
Sign up to request clarification or add additional context in comments.

6 Comments

Oh, I see. Works fine. Ty :)
Common enough mistake, I've done it a ton of times myself.
Another question: Is it possible to use a variable, lets call it x, in the CellRef part of it? I know it clearly say CellRef, but maybe there is a way around
As long as variable x is defined as a Range variable (ie 'Dim x As Range') and it's set properly, that should work.
It did, thanks again. But one last question: it is not possible to write the results from the solver directly to an array, is it?
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.