Originally posted by: BL_G
Hello,
I am using CPLEX 12.2.0.2 and Microsoft Excel 2007 and I am experiencing problems with the VBA functions for CPLEX. The files cplex122.xll and cplexvba.bas are installed / added to Excel.
Even though the Excel GUI works fine, I am receiving following 2 errors (also at the 3 excel VBA examples provided with the software):
1. at first it tells me that the formula is not correct
2. then I receive the message: "Failed to setup optimization problem. Error 22: No variable cells defined".
How can I solve this problem?
Thanks,
Bernard
I also created my own example (one objective, 2 constraints, which gives the same error messages:
Sub start()
Dim rngVar As Range
Dim rngCon As Range
Dim rngConUb As Range
Dim rngObj As Range
Set rngVar = Worksheets("Tabelle1").Range(Tabelle1.Cells(7, 2), Tabelle1.Cells(16, 2))
Set rngCon = Tabelle1.Range("e18:f18")
Set rngConUb = Tabelle1.Range("e3:f3")
Set rngObj = Tabelle1.Cells(18, 2)
cplexvba.CPXclear
cplexvba.CPXsetObjective ObjCell:=rngObj, Sense:=1
cplexvba.CPXaddVariable Variable:=rngVar, Lb:=0, Ub:=1
cplexvba.CPXaddConstraint Constraint:=rngCon, Ub:=rngConUb
cplexvba.CPXsolve
End Sub
#CPLEXOptimizers#DecisionOptimization