Hello everyone,
I have a problem with solver code, this is my code:
This code does not work all the time. Sometimes it does not recognise the
ValueOf:="$g$322". When I replace it with the number (for example 35) it does work. The problem is that the value of g322 is not the same for all the problems. It is a reference cell. Any help please?
Niki
I have a problem with solver code, this is my code:
Code:
Private Sub CommandButton1_Click()
Worksheets("teliko").Activate
solverReset
SolverOk SetCell:="$g$318", MaxMinVal:=3, ValueOf:="$g$322", ByChange:="$c$26:$c$35"
Dim i As Integer, s As String, m As Integer
m = 393
For i = 322 To m Step 1
s = VBA.Format(i, "0")
SolverAdd CellRef:="$f$ & s", _
Relation:=1, _
FormulaText:="$g$ & s- 1"
Next i
SolverSolve
ActiveWorkbook.RefreshAll
End Sub
This code does not work all the time. Sometimes it does not recognise the
ValueOf:="$g$322". When I replace it with the number (for example 35) it does work. The problem is that the value of g322 is not the same for all the problems. It is a reference cell. Any help please?
Niki