Comments on: OpenSolver API Reference https://opensolver.org The Open Source Optimization Solver for Excel Wed, 29 Oct 2025 05:54:28 +0000 hourly 1 By: Utilização do OpenSolver com VBA | Ferramentas em Excel-Vba https://opensolver.org/opensolver-api-reference/comment-page-2/#comment-535858 Fri, 16 Sep 2022 23:15:50 +0000 http://opensolver.org/?page_id=770#comment-535858 […] referência para os comandos pode ser consultada em https://opensolver.org/opensolver-api-reference. Outra forma é consultando direto o código VBA do OpenSolver, ele detalha bem a forma de […]

]]>
By: Ed https://opensolver.org/opensolver-api-reference/comment-page-2/#comment-457560 Thu, 03 Feb 2022 20:37:24 +0000 http://opensolver.org/?page_id=770#comment-457560 I have a model in which I am trying to do several iterations with changing some named range parameters. It works great, but after every iteration the problem needs to be setup again. Is there a way to just update the certain parameters and not have to reload the whole problem?
I have used SetQuickSolveParameters to indicate the parameters that are changing, the model solves, but the results don’t make sense compared to running the model with setting up the problem again.

This is the current order of calls:
SetQuickSolverParameters(ActiveSheet.Range(“namedRanges”))
RunQuickSolve()
… parameters get updated, then:
SetQuickSolverParameters(ActiveSheet.Range(“namedRanges”))
RunQuickSolve()…

I have tried several iterations with GetQuickSolveParameters too, but haven’t been successful. If you have any insights please let me know. Thanks.

]]>
By: Andrew Mason (Team OpenSolver) https://opensolver.org/opensolver-api-reference/comment-page-2/#comment-441988 Fri, 18 Jun 2021 05:35:56 +0000 http://opensolver.org/?page_id=770#comment-441988 In reply to Flint.

If it runs a long time, then CBC cannot tell that it is infeasible. So, sorry, but there is not shortcut for determining this. Andrew

]]>
By: Flint https://opensolver.org/opensolver-api-reference/comment-page-2/#comment-437770 Tue, 01 Jun 2021 15:16:40 +0000 http://opensolver.org/?page_id=770#comment-437770 Good Morning,

I have a dynamic model that is working great! The problem that I have been running into though is that some user set constraints can produce an infeasible solution. There is no error code popup that is produced when this happens, solver will just run for a very extended amount of time.

Is there some code that I could add to get the status or error code so that I can create a message box that will inform the user that they need to adjust some of the constraints?

The main thing that I need is a line of code that will produce the error code (i.e. 5 – infeasible solution)

]]>
By: Krishna Mahale https://opensolver.org/opensolver-api-reference/comment-page-2/#comment-359491 Thu, 21 May 2020 14:21:49 +0000 http://opensolver.org/?page_id=770#comment-359491 Hi,

Trust you are doing well.
I am trying to use a call to SetDecisionVariables using named ranges. Is that possible? Whats the syntax to be followed?

Thanks.
KM

]]>
By: Andrew Mason (Team OpenSolver) https://opensolver.org/opensolver-api-reference/comment-page-2/#comment-331397 Fri, 22 Nov 2019 17:30:58 +0000 http://opensolver.org/?page_id=770#comment-331397 In reply to Atchoum.

Thanks for the helpful reply. Andrew

]]>
By: Atchoum https://opensolver.org/opensolver-api-reference/comment-page-2/#comment-331394 Fri, 22 Nov 2019 14:26:11 +0000 http://opensolver.org/?page_id=770#comment-331394 In reply to Mattia.

You should look at following post (in older comments section)
—–
Jack says:
July 7, 2015 at 3:16 am
Thanks for trying out the API and letting us know! The problem here is that the `Sheet` argument needs to be a Worksheet object rather than a String. I’ve fixed up the code to use a Worksheet object here: https://gist.github.com/JackDunnNZ/917ad455b290161ed59d

There are a couple of other changes I made:

You don’t need to select the sheet before making changes to the model
You need to set all the decision variables in one call to `SetDecisionVariables`. The way to do this is to use the `Union` function of VBA
Please let me know if there’s anything not clear or if you have any other problems.

]]>
By: Kentaro https://opensolver.org/opensolver-api-reference/comment-page-1/#comment-330031 Sun, 10 Nov 2019 14:05:01 +0000 http://opensolver.org/?page_id=770#comment-330031 In reply to Robert Cleveland Abbe.

Nice to meet you.
I have seen the same error message.
When the Excel sheet name was “Ax = b”, an error occurred, and if the name was changed to a name that did not include “=”, it could be executed without any problems.
——-
Windows 10, Excel 2016

]]>
By: Mattia https://opensolver.org/opensolver-api-reference/comment-page-2/#comment-321295 Fri, 09 Aug 2019 18:36:39 +0000 http://opensolver.org/?page_id=770#comment-321295 Hello, I’m having difficulties in 2 things using Opensolver in VBA (I’m a noob, i know it):
1) I need to declare different ranges of variables, so I tried
‘OpenSolver.SetDecisionVariables WSheet.Range(“D4:FJ4”), sheet:=WSheet
‘OpenSolver.SetDecisionVariables WSheet.Range(“D5:D125”), sheet:=WSheet
‘OpenSolver.SetDecisionVariables WSheet.Range(“E125:GK125”), sheet:=WSheet
‘OpenSolver.SetDecisionVariables WSheet.Range(“GK58:GK124”), sheet:=WSheet
‘OpenSolver.SetDecisionVariables WSheet.Range(“FI58:GJ58”), sheet:=WSheet
‘OpenSolver.SetDecisionVariables WSheet.Range(“FI59:FI124”), sheet:=WSheet
‘OpenSolver.SetDecisionVariables WSheet.Range(“AC86:FH86”), sheet:=WSheet
‘OpenSolver.SetDecisionVariables WSheet.Range(“AB5:AB97”), sheet:=WSheet
‘OpenSolver.SetDecisionVariables WSheet.Range(“AC28:FJ28”), sheet:=WSheet
‘OpenSolver.SetDecisionVariables WSheet.Range(“FJ5:FJ27”), sheet:=WSheet
‘OpenSolver.SetDecisionVariables WSheet.Range(“DX5:DX27”), sheet:=WSheet
‘OpenSolver.SetDecisionVariables WSheet.Range(“BX5:BX27”), sheet:=WSheet
‘OpenSolver.SetDecisionVariables WSheet.Range(“E67:AA67”), sheet:=WSheet
‘OpenSolver.SetDecisionVariables WSheet.Range(“E98:FI98”), sheet:=WSheet
‘OpenSolver.SetDecisionVariables WSheet.Range(“BJ87:BJ124”), sheet:=WSheet
‘OpenSolver.SetDecisionVariables WSheet.Range(“DI99:DI124”), sheet:=WSheet
‘OpenSolver.SetDecisionVariables WSheet.Range(“FJ95:GJ95”), sheet:=WSheet
‘OpenSolver.SetDecisionVariables WSheet.Range(“FH80”), sheet:=WSheet
But in the end I have only the last (FH80) as a variable, like it is overwriting and not updating.

Then I tried :
OpenSolver.SetDecisionVariables WSheet.Range(“D4:FJ4”, “D5:D125”, “E125:GK125”,
“GK58:GK124”, “FI58:GJ58”, “FI59:FI124”, “AC86:FH86”, “AB5:AB97”, “AC28:FJ28”, “FJ5:FJ27”,
“DX5:DX27”, “BX5:BX27”, “E67:AA67”, “E98:FI98”, “BJ87:BJ124”, “DI99:DI124”, “FJ95:GJ95”,
“FH80”), sheet:=WSheet
But it gives me a error, saying that the number of arguments is wrong.
How could I do this?

2) Then, i have some particular cells in which i have writed a string like “Range(“AM98″)”, can I use this cells as parameters?
Example:
Dim Elemento_Corrente As String
Elemento_Corrente = “Range(“AM98″)”
OpenSolver.AddConstraint WSheet.Range(Elemento_Corrente), RelationEQ, RHSFormula:=”1″, sheet:=WSheet

Thank you very much, this will be foundamental for my my degree thesis.
Mattia

]]>
By: Andrew Mason (Team OpenSolver) https://opensolver.org/opensolver-api-reference/comment-page-2/#comment-318588 Tue, 28 May 2019 10:20:41 +0000 http://opensolver.org/?page_id=770#comment-318588 In reply to Júlia.

Just change the formula in C12 to =D24. Andrew

]]>