简体   繁体   English

VBA中的Excel规划求解命名范围

[英]Excel Solver Named Ranges in VBA

Is it possible to amend the vba script so that in defining the parameters for 'Solver' I can used the 'Names' for the various ranges instead of the absolute cell references? 是否可以修改vba脚本,以便在定义“ Solver”的参数时可以将“ Names”用于各个范围,而不是绝对单元格引用?

In the example below the various ranges are defined in the spreadsheet as; 在下面的示例中,电子表格中将各种范围定义为:

$A$1 ..... "obj_func"
$E$8:$E$11,$I$8:$M$11 ..... "bin_var", "qty_cut"
$C$8:$C$11 ..... "qty_used"



SolverOk SetCell:="$A$1", MaxMinVal:=2, ValueOf:=0, ByChange:= _
"$E$8:$E$11,$I$8:$M$11", Engine:=2, EngineDesc:="Simplex LP"

SolverAdd CellRef:="$C$8:$C$11", Relation:=1, FormulaText:="stock_lengths"

UNTESTED 未测试

Try replacing: 尝试更换:

SolverAdd CellRef:="$C$8:$C$11", Relation:=1, FormulaText:="stock_lengths"

with: 与:

SolverAdd CellRef:=Range("qty_used").Address, Relation:=1, FormulaText:="stock_lengths"

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM