Ok first time trying this with solver and putting my hands up my VBA is crap but attempt here to
Trying to get total to 39 by adjusting values in c3 to c7 with variables as seen in code below and so on across the columns, seems to jump across columns ok but see no change in data, what am i doing wrong?
Thanks for the helps folks.
VBA Code:
Sub Solve()
'
' Solve Macro
'
Dim rng As Range
For i = 4 To 8
Columns(i).Select
SolverReset
SolverOk SetCell:="$" & i & "$13", MaxMinVal:=3, ValueOf:="39.00", ByChange:="$" & i & "$2:""$" & i & "$7" _
, Engine:=1, EngineDesc:="GRG Nonlinear"
SolverAdd CellRef:="$" & i & "$3", Relation:=1, FormulaText:="6"
SolverAdd CellRef:="$" & i & "$3", Relation:=3, FormulaText:="2"
SolverAdd CellRef:="$" & i & "$4", Relation:=3, FormulaText:="0.5"
SolverAdd CellRef:="$" & i & "$4", Relation:=1, FormulaText:="2"
SolverAdd CellRef:="$" & i & "$6", Relation:=1, FormulaText:="35"
SolverAdd CellRef:="$" & i & "$6", Relation:=3, FormulaText:="15"
SolverAdd CellRef:="$" & i & "$7", Relation:=3, FormulaText:="2"
SolverAdd CellRef:="$" & i & "$7", Relation:=3, FormulaText:="2"
SolverSolve UserFinish:=True
SolverFinish KeepFinal:=1
Next i
End Sub
Thanks for the helps folks.
Project hrs.xlsm | |||||||
---|---|---|---|---|---|---|---|
B | C | D | E | F | |||
1 | Jobs | Week1 | Week2 | Week3 | Week4 | ||
2 | a | 2.5 | 1 | 1.25 | 3 | ||
3 | b | 5.5 | 5 | 4 | 7 | ||
4 | c | 1.5 | 2 | 2 | 1 | ||
5 | d | 3.833333 | |||||
6 | e | 19.83333 | 17 | 29 | 21 | ||
7 | f | 5.833333 | 2 | 3 | 7 | ||
8 | g | ||||||
9 | h | ||||||
10 | i | ||||||
11 | j | ||||||
12 | k | ||||||
13 | Total | 39 | 26 | 38 | 36 | ||
Sheet1 |
Cell Formulas | ||
---|---|---|
Range | Formula | |
C13:F13 | C13 | =SUM(C2:C12) |
Named Ranges | ||
---|---|---|
Name | Refers To | Cells |
solver_lhs1 | =Sheet1!$C$3 | C13 |
solver_lhs10 | =Sheet1!$C$3 | C13 |
solver_lhs11 | =Sheet1!$C$4 | C13 |
solver_lhs12 | =Sheet1!$C$4 | C13 |
solver_lhs13 | =Sheet1!$C$6 | C13 |
solver_lhs14 | =Sheet1!$C$6 | C13 |
solver_lhs15 | =Sheet1!$C$7 | C13 |
solver_lhs16 | =Sheet1!$C$7 | C13 |
solver_lhs17 | =Sheet1!$C$3 | C13 |
solver_lhs18 | =Sheet1!$C$3 | C13 |
solver_lhs19 | =Sheet1!$C$4 | C13 |
solver_lhs2 | =Sheet1!$C$3 | C13 |
solver_lhs20 | =Sheet1!$C$4 | C13 |
solver_lhs21 | =Sheet1!$C$6 | C13 |
solver_lhs22 | =Sheet1!$C$6 | C13 |
solver_lhs23 | =Sheet1!$C$7 | C13 |
solver_lhs24 | =Sheet1!$C$7 | C13 |
solver_lhs25 | =Sheet1!$C$3 | C13 |
solver_lhs26 | =Sheet1!$C$3 | C13 |
solver_lhs27 | =Sheet1!$C$4 | C13 |
solver_lhs28 | =Sheet1!$C$4 | C13 |
solver_lhs29 | =Sheet1!$C$6 | C13 |
solver_lhs3 | =Sheet1!$C$4 | C13 |
solver_lhs30 | =Sheet1!$C$6 | C13 |
solver_lhs31 | =Sheet1!$C$7 | C13 |
solver_lhs32 | =Sheet1!$C$7 | C13 |
solver_lhs33 | =Sheet1!$C$3 | C13 |
solver_lhs34 | =Sheet1!$C$3 | C13 |
solver_lhs35 | =Sheet1!$C$4 | C13 |
solver_lhs36 | =Sheet1!$C$4 | C13 |
solver_lhs37 | =Sheet1!$C$6 | C13 |
solver_lhs38 | =Sheet1!$C$6 | C13 |
solver_lhs39 | =Sheet1!$C$7 | C13 |
solver_lhs4 | =Sheet1!$C$4 | C13 |
solver_lhs40 | =Sheet1!$C$7 | C13 |
solver_lhs5 | =Sheet1!$C$6 | C13 |
solver_lhs6 | =Sheet1!$C$6 | C13 |
solver_lhs7 | =Sheet1!$C$7 | C13 |
solver_lhs8 | =Sheet1!$C$7 | C13 |
solver_lhs9 | =Sheet1!$C$3 | C13 |