@@ -12,7 +12,7 @@ Attribute VB_Description = "A class to set/manage Solver constraints."
1212'@Exposed
1313'@folder("SolverWrapper.Source")
1414' ==========================================================================
15- ' SolverWrapper v0.8
15+ ' SolverWrapper v0.9
1616'
1717' A wrapper for automating MS Excel's Solver Add-in
1818'
@@ -60,10 +60,6 @@ Private oSolverSheet As Worksheet
6060'%Description("Adds a constraint to the current problem.")
6161Public Sub Add (ByVal cellRef As Variant , ByVal relation As SlvRelation , Optional ByVal formulaText As Variant )
6262Attribute Add.VB_Description = "Adds a constraint to the current problem."
63- If Me.Count + 1 > 100 Then
64- Err.Raise vbObjectError + 4001 , , "Number of Constraints must be less than or equal to 100"
65- End If
66-
6763 Dim ws As Worksheet
6864 Dim solver_num As Long
6965
@@ -291,13 +287,13 @@ Private Sub ProcessConstraintParams(ByRef cellRef As Variant, ByVal relation As
291287 Err.Raise vbObjectError + 4001 , , "Please specify a valid cell reference"
292288 End If
293289
294- 'could do this check in SolveIt right before calling dll - that way user can do things in any order
295- 'check that lhs refer(s) to the decision variables
296290 If relation > 3 Then
291+ 'LHS MUST refer to the decision variables
292+ 'and thus dose not count against the 100-cell constraint limit
297293 If Not NameExists("solver_adj" , ws) Then
298294 Err.Raise vbObjectError + 4001 , , "Cannot set constraint relations slvInt, slvBin, or slvAllDif, until after the decision variables are defined."
299295 End If
300- If Not IsRangeInRange(ws.Range(cellRef), ws.Range(ws. Names("solver_adj" ).Name) ) Then
296+ If Not IsRangeInRange(ws.Range(cellRef), ws.Names("solver_adj" ).RefersToRange ) Then
301297 'the int, bin, and alldifferent constraints can only be applied to decision vars
302298 Err.Raise vbObjectError + 4001 , , "The selected Relation only applies to contraints on decision variables."
303299 End If
0 commit comments