简体   繁体   中英

How to delete all constraints from solver in Excel?

I can use SolverDelete to delete a constraint if I know exactly what it looks like.

How can I delete all constraints with VBA without knowing them?

You can use the SolverGet Function.

SolverGet(TypeNum, SheetName)

TypeNum is a required Integer. A number specifying the type of information you want. The following settings are specified in the Solver Parameters dialog box.

The TypeNum parameters you need are:

5, The number of constraints.
6, An array of the left sides of the constraints, in text form.
7, An array of numbers corresponding to the relationships between the left and right sides of the constraints: 1 represents <=, 2 represents =, 3 represents >=, 4 represents int, and 5 represents bin.
8, An array of the right sides of the constraints, in text form.

See Excel Help on SolverGet for more details.

如果您不知道所有参数,则可以使用SolverReset。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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