Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/vba/17.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Can';t将我的函数添加到Excel VBA_Excel_Vba_Colors_Cell - Fatal编程技术网

Can';t将我的函数添加到Excel VBA

Can';t将我的函数添加到Excel VBA,excel,vba,colors,cell,Excel,Vba,Colors,Cell,所以我从另一个网站上下载了这个程序,所以它不是我的 Function InteriorColor(CellColor As Range) Application.Volatile True InteriorColor = CellColor.Interior.ColorIndex End Function 我将其添加到excel中的VBA中,但我得到了#名称?错误,我确保我将其设置为启用所有宏,因此我并不真正理解错误 我用过这个 =InteriorColor(AQ113)

所以我从另一个网站上下载了这个程序,所以它不是我的

Function InteriorColor(CellColor As Range)
     Application.Volatile True
    InteriorColor = CellColor.Interior.ColorIndex
End Function
我将其添加到excel中的VBA中,但我得到了#名称?错误,我确保我将其设置为启用所有宏,因此我并不真正理解错误

我用过这个

=InteriorColor(AQ113)

在单元格中

阅读您的评论后,我怀疑您已将代码放在编辑器中的
此工作簿

您应该右键单击项目->插入->模块,然后将代码粘贴到新模块中


将函数复制到任何模块中。您将函数放在哪里可能会对您有所帮助。好的,我将它放在一个模块中,但仍然会出现错误,我刷新了它。我真的不明白为什么会出现错误,我把它放在了我想要使用它的同一个工作簿中。在将代码移动到模块后,您会收到什么错误消息?以防万一OP误解了
模块的含义。所以,为了让它更明确,如果你也添加图像,它会更有帮助。我在模块中得到了它,但现在正如我所说,我得到了一个#值!errorI used=InteriorColor(AQ110),该单元格的颜色为红色,因此应返回3。