Excel规划求解VBA [英] Excel Solver VBA

查看:147
本文介绍了Excel规划求解VBA的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Excel VBA宏中创建的求解器模型中的一个方程如下:

One of the equations in a Solver model that I am creating in an Excel VBA macro is as follows:

SolverAdd CellRef:="$M$18:$M$30", Relation:=2, FormulaText:="$N$18:$N$30"

我如何实现它,以使行号"18"是可以从另一个单元格读取的值?例如,单元格A1的值可能为18,这是我要在此等式中使用的值.如果A1中的值为10,则等式应为:

How could I implement it so that the row number "18" is a value that can be read as an input from another cell? For example, cell A1 may have the value 18, which is what I want used in this equation. If the value in A1 was 10, then the equation should read as:

SolverAdd CellRef:="$M$10:$M$30", Relation:=2, FormulaText:="$N$10:$N$30"

类似地,变量定义为:

SolverOk SetCell:="$H$47", MaxMinVal:=2, ValueOf:=0, ByChange:="$H$18:$J$30,$R$18:$R$30", _
    Engine:=1, EngineDesc:="Simplex LP"

同样,当单元格A1中的数字值从18变为10时,变量应从"$ H $ 18:$ J $ 30,$ R $ 18:$ R $ 30" 更改为"$ H $ 10:$ J $ 30,$ R $ 10:$ R $ 30" .

Again, when the value of the number in cell A1 changes from, say 18 to 10, the variables should change from "$H$18:$J$30,$R$18:$R$30" to "$H$10:$J$30,$R$10:$R$30".

我将不胜感激任何建议.

I will greatly appreciate any suggestions.

非常感谢.

推荐答案

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆