本文介绍了从excel单元格调用excel工作表函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一组用户定义的vba函数,它们位于一个excel模块中,然后从excel电子表格中调用...所有这一切都在正常工作。

I have a set of user defined vba functions that sit in an excel module, which are then called from an excel spreadsheet... everything has worked fine at this point.

我被要求将vba从模块移动到工作表的代码页。当我这样做,我发现我不能调用工作表上的单元格的任何功能...名称根本不显示为现有。有没有办法从excel单元格中调用工作表函数?另外,在另一个模块或工作表代码中用户定义的函数调用工作表函数有什么问题吗?

I've been asked to move the vba from the module to the worksheet's code page. When I did this, I've found I can't call any of the functions from cells on the worksheet... the names simply don't show as existing. Is there a way to call worksheet functions from an excel cell? Also, is there any problem calling a worksheet function from a user defined function in another module or worksheet code behind?

编辑:

我发现如果我通过sheetname.functionname调用,它会抛出一个错误消息,其中包含与Excel内置名称或名称冲突的名称另一个对象在工作簿中...如果我使用sheetname.anythingelse它只是解决#NAME?

I've found if I call by the sheetname.functionname, it throws an error message that includes "The name conflicts with an Excel built-in name or the name of another object in the workbook"... where if I use sheetname.anythingelse it just resolves to #NAME?

这是否意味着excel工作表函数不能从一个表格?

Does this mean excel worksheet functions cannot be called from a sheet?

推荐答案

否。工作表对象中的函数不能作为用户定义的函数从工作表中调用。

No. Functions in the worksheet object can't be called from the sheet as user-defined functions.

Worksheet对象旨在响应工作表上发生的事件。您不能将用户定义的函数放在那里。用户定义的函数必须存在于模块中。

The Worksheet object is intended for responding to events that happen on a worksheet. You can't put user-defined functions there. User defined functions have to live in a Module.

如果您的用户定义函数存在于模块中,则不会在其他任何地方调用代码...包括在工作表代码隐藏。

If your user-defined function does live in a module, you won't have any problem calling it from code anywhere else... including in the worksheet "code-behind".

这篇关于从excel单元格调用excel工作表函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-23 21:36