首页 > 解决方案 > Excel VBA:从一个工作表调用一个函数,该函数在不同工作表上搜索数据

问题描述

我有一个包含几张数据的工作簿。

在其他表上,我需要在其中一个数据表上进行搜索。

在我用来开始搜索的函数中,我有一个名为 firstcell 的参数,它告诉搜索函数从哪里开始。

发生的情况是搜索函数认为 firstcell 在调用函数所在的工作表上,而不是数据表上。

如何将正确的工作表传递给搜索功能?

Function GetValue(firstcell as string, searchterms) As Variant

''firstcell is the name of a named cell on the data sheet
''searchterms is a list of values that gets passed

. . . .

    GetValue = MySearch(Range(firstcell), searchterms)

'' this is where firstcell becomes the address of the named cell but on the sheet where the function is
. . . .


End Function    'GetValue

谢谢

标签: excelvba

解决方案


推荐阅读