VBA 求解器编译错误:未定义子或函数

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/43116938/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-12 12:22:17  来源:igfitidea点击:

VBA Solver Compile Error: Sub or Function not defined

excelvbareferencecompiler-errorssolver

提问by Zayd Husseini-Eyre

I am using office 365 for Mac, with version number 15.32.

我使用的是 Office 365 for Mac,版本号为 15.32。

I repeatedly get the "compile error: sub or function not defined" when I try to run the macro that is trying to implement a solver function, which was a previously recorded macro (so I know it is correct). The error highlights the "SolverOk" part of the code.

当我尝试运行试图实现求解器函数的宏时,我反复收到“编译错误:子或函数未定义”,这是一个以前记录的宏(所以我知道它是正确的)。该错误突出显示了代码的“SolverOk”部分。

I understand that this often occurs when the reference to Solver.xlam is not present, however I have no idea how to do this on the Mac if this is truly the issue. Attached is a screenshot of what I am trying to achieve. Does the Solver.xlam thing on the left indicates that it is there? If so, do you have any idea what the problem is?

我知道这通常发生在对 Solver.xlam 的引用不存在时,但是如果这确实是问题,我不知道如何在 Mac 上执行此操作。附件是我试图实现的屏幕截图。左边的 Solver.xlam 东西是否表明它在那里?如果是这样,您知道问题出在哪里吗?

Screenshot of available references

可用参考的屏幕截图

Screenshot of error + VBA code

错误截图 + VBA 代码

采纳答案by SLWS

Open File/Options/Add-Ins

打开文件/选项/加载项

On the page with the add ins, click on the bottom "Manage Excel Add-Ins" .. "Go..." and look for SOLVER related Add-ins there.

在带有加载项的页面上,单击底部的“管理 Excel 加载项”..“转到...”并在那里查找与 SOLVER 相关的加载项。

Once these are activated, return to VBA (Alt-F11) and then the "SOLVER" option should be available in Tools/References, where you want to Add it.

一旦这些被激活,返回到 VBA (Alt-F11),然后“求解器”选项应该在工具/参考中可用,你想添加它。