hasselberg
New Member
- Joined
- Jun 8, 2021
- Messages
- 1
- Office Version
- 365
- Platform
- Windows
Hello,
I have a macro that runs Solver in Excel, it currently uses two different ranges as the variable cells. See the code below.
Instead of having an absolute reference to $C$7:$I$11, I would want to only select the rows of the range where K7:K11="Unlocked" (note that this is a separate column). Is it possible to achieve in a simple way? I have attempted creating a named range in Excel, but I have so far been unsuccessful. Maybe it's easier to solve within the macro, however my VBA skills are nonexistant.
Thankful for any help!
I have a macro that runs Solver in Excel, it currently uses two different ranges as the variable cells. See the code below.
VBA Code:
SolverOk SetCell:="$D$27", MaxMinVal:=2, ValueOf:=0, ByChange:= _
"$C$17:$C$23,$C$7:$I$11", Engine:=1, EngineDesc:="GRG Nonlinear"
SolverOptions MaxTime:=30, Iterations:=0, Precision:=0.9, Convergence:= _
0.9, StepThru:=False, Scaling:=False, AssumeNonNeg:=True, Derivatives:=1
SolverOptions PopulationSize:=200, RandomSeed:=0, MutationRate:=0.999, Multistart _:=False, RequireBounds:=True, MaxSubproblems:=0, MaxIntegerSols:=0, _
IntTolerance:=0#, SolveWithout:=False, MaxTimeNoImp:=30
SolverSolve userFinish:=True, ShowRef:=0
SolverFinish KeepFinal:=1
Instead of having an absolute reference to $C$7:$I$11, I would want to only select the rows of the range where K7:K11="Unlocked" (note that this is a separate column). Is it possible to achieve in a simple way? I have attempted creating a named range in Excel, but I have so far been unsuccessful. Maybe it's easier to solve within the macro, however my VBA skills are nonexistant.
Thankful for any help!