简体   繁体   English

在Mac上的Excel VBA中使用求解器

[英]Using solver in Excel VBA on mac

I want to automate a series of solver operations in a VBA macro in Excel 2016 for mac. 我想在Mac版Excel 2016中的VBA宏中自动化一系列求解器操作。 However, when I run the macro an error keeps popping up. 但是,当我运行宏时,错误不断弹出。 The error I get is "Sub of function not defined". 我得到的错误是“未定义功能子”。 The code I use is the following. 我使用的代码如下。

 Sub test_test_test() ' ' test_test_test Macro ' SolverOk SetCell:="$K$3", MaxMinVal:=3, ValueOf:=-20, ByChange:="$K$3", Engine:=1, EngineDesc:="GRG Nonlinear" SolverSolve End Sub 

Thanks a lot! 非常感谢! Lennart 伦纳特

You should add solver to references. 您应该将求解器添加到引用中。

To do so, open visual basic editor. 为此,打开Visual Basic编辑器。 There is "Add References ...." button on bottom left of the editor. 在编辑器的左下角有“添加引用...”按钮。 Click it, check the box for Solver, then click OK. 单击它,选中“求解器”框,然后单击“确定”。 This should work. 这应该工作。

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

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