简体   繁体   English

无法将我的功能添加到Excel VBA

[英]Can't add my function to the Excel VBA

So I pulled this program from another website so it's not mine. 所以我从另一个网站上撤了这个程序,所以它不是我的。

Function InteriorColor(CellColor As Range)
     Application.Volatile True
    InteriorColor = CellColor.Interior.ColorIndex
End Function

And I added it to the VBA in excel yet I get #NAME? 然后我将它添加到excel的VBA中,但是却获得了#NAME? error, I made sure that I set it to Enable All Macros, so I don't really understand the error. 错误,我确保将其设置为“启用所有宏”,因此我并不真正理解该错误。

I used this 我用这个

=InteriorColor(AQ113)

In the cell 在单元格中

After reading your comments, I suspect you have put the code under ThisWorkbook in the editor. 阅读您的评论后,我怀疑您已将代码放在编辑器中的ThisWorkbook下。

You should right click the project -> Insert -> Module, then paste the code in the new module 您应该右键单击项目->插入->模块,然后将代码粘贴到新模块中

在此处输入图片说明

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

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