Solver and Dynamic Named Ranges

Ritzyy

New Member
Joined
Jan 28, 2013
Messages
29
Hi,

Is it possible to use a dynamic named range to define a constraint or the variable cells in solver? Currently I have a name "Iterations" defined as =OFFSET($I$6,,,COUNTA($I:$I)-1), however, when I go to include this on the LHS of a constraint, as soon as I click 'Add' the constraint, the name range simple changes to $I$6:$I$22 and no longer references the name.

Any help would be appreciated!
 

Excel Facts

Format cells as currency
Select range and press Ctrl+Shift+4 to format cells as currency. (Shift 4 is the $ sign).
Hi

You can use VBA to dynamically define the range and execute Solver:


Code:
Sub Dyn()
SolverOk SetCell:="$D$6", MaxMinVal:=1, ValueOf:="0", _
ByChange:="$b$3:$b$" & Evaluate("=counta($b:$b)")
solversolve userfinish:=True
End Sub
 
Upvote 0
Hi

You can use VBA to dynamically define the range and execute Solver:


Code:
Sub Dyn()
SolverOk SetCell:="$D$6", MaxMinVal:=1, ValueOf:="0", _
ByChange:="$b$3:$b$" & Evaluate("=counta($b:$b)")
solversolve userfinish:=True
End Sub

Epic, thanks mate!
 
Upvote 0

Forum statistics

Threads
1,215,492
Messages
6,125,115
Members
449,206
Latest member
burgsrus

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top