Excel VBA 自定义函数不能执行,怎么办?(2014.1.6)

标签:
it |
原文见:http://zhidao.baidu.com/question/95633422.html
在 EXCEL 中,除了用Excel 提供的函数外,还可以用VBA 自已编各种功能的函数, 我以前编的都没有出过问题. 但不知为什么,我发现VBA 编的函不能运行了. 比如随便看下面一个函数:
Excel VBA sheet1 模块下编写:
function myfunction(x as integer) as long
myfunction=x*x
end function
在Excel 中 A1 输入3,B1 中输入:=myfunction(A1)
回车后,显示 #NAME , 智能标记显示"元效名称错误"
请问是什么地方出了问题?我猜可能是Excel 的什么服务被关了,但不知道具体情况,盼各位大虾帮忙!
http://f.hiphotos.baidu.com/zhidao/wh=450,600/sign=8a76e32ac93d70cf4cafa209cdecfd36/adaf2edda3cc7cd9785885ca3901213fb80e91a8.jpgVBA
解决办法:
不要放sheet1 模块下,你右键---插入--模块,把代码放在这个模块里,就可以运行了。
2014.1.6日于杭州