工作表未找到 Excel VBA 宏,#NAME

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/11002083/
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-11 16:28:28  来源:igfitidea点击:

Excel VBA macro not found by worksheet, #NAME

excelvba

提问by Hyman BeNimble

I'm trying to get a simple VBA function to run in an excel (.xlsm) worksheet.

我试图让一个简单的 VBA 函数在 excel (.xlsm) 工作表中运行。

I created this function:

我创建了这个函数:

Function abc()

abc = 2

End Function

in Module2, and it worked.

在 Module2 中,它起作用了。

But after I copied the spreadsheet to another system, it now just shows "#name" as if it can't find it. The function shows up on the available list of functions however.

但是在我将电子表格复制到另一个系统后,它现在只显示“#name”,好像找不到它一样。然而,该函数显示在可用的函数列表中。

This makes me think there is some kind of setting I need to enable, but I've enabled whatever I was prompted for. Any ideas?

这让我觉得我需要启用某种设置,但我已经启用了我提示的任何设置。有任何想法吗?

回答by Hyman BeNimble

I should've known it was in the trust center:

我应该知道它在信任中心:

http://office.microsoft.com/en-us/excel-help/change-macro-security-settings-in-excel-HP010096919.aspx

http://office.microsoft.com/en-us/excel-help/change-macro-security-settings-in-excel-HP010096919.aspx

Basically, hit the ball and poke around until you find "trust" and "enable macros" and select the least secure options.

基本上,击球并四处寻找,直到找到“信任”和“启用宏”并选择最不安全的选项。

And then close and re-open the spreadsheet.

然后关闭并重新打开电子表格。

回答by Jomtung

I think we may need more information. What version of Excel are you using? Is it different from the destination system version?

我想我们可能需要更多信息。你用的是什么版本的Excel?它与目标系统版本不同吗?

You'll want to make sure that Module2 was in the Workbook you copied into the other system. Excel 2007 stores macros on a personal workbook by default sometimes so you'll need to check the the code is actually inside of the .xlsm file.

您需要确保 Module2 位于您复制到另一个系统中的工作簿中。Excel 2007 有时默认将宏存储在个人工作簿上,因此您需要检查代码实际上是否在 .xlsm 文件中。

If you're still stuck and need a quick fix just copy the code text into the new system's Excel workbook directly without making a .xlsm file (create new module in the other system then paste).

如果您仍然卡住并需要快速修复,只需将代码文本直接复制到新系统的 Excel 工作簿中,而无需创建 .xlsm 文件(在其他系统中创建新模块然后粘贴)。

If you would like to learn how to put together add-ins you can get started hereor here.

如果您想学习如何组合加载项,您可以从这里这里开始。