Hi,
I am trying to enter two variable cell references via a macro into the excel solver to allow me to solve multiple cells. I can do this if I have a single variable cell, but not for multiple cells. Here is my code, any ideas?
I keep getting the "Expected: end of statement error when I compile.
Dim i As Integer
Dim x As String
For i = 12 To 26
SolverReset
x = "$C$" & i "," "$L$" & i
SolverOk SetCell:="$BM$" & i, MaxMinVal:=2, ValueOf:="0", ByChange:=x
SolverAdd CellRef:="$P$" & i, Relation:=3, FormulaText:="$D$5"
SolverAdd CellRef:="$R$" & i, Relation:=3, FormulaText:="$Q$" & i
SolverAdd CellRef:="$AF$" & i, Relation:=3, FormulaText:="$D$6"
SolverAdd CellRef:="$AO$" & i, Relation:=3, FormulaText:="$AK$" & i
SolverAdd CellRef:="$AR$" & i, Relation:=3, FormulaText:="$AL$" & i
SolverOk SetCell:="$BM$" & i, MaxMinVal:=2, ValueOf:="0", ByChange:=x
SolverSolve
SolverSolve UserFinish:=True
SolverFinish KeepFinal:=1
SendKeys "{ENTER}"
Next i
The red line is the one causing the problems. I want to vary the row aka the i value.
Cheers
Guern
Bookmarks