Excel VBA:从一张工作表中调用在另一张工作表上搜索数据的函数

问题描述 投票:0回答:1

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

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

在我用来开始搜索的函数中,我有一个名为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

谢谢

excel vba
1个回答
0
投票

确定。我是Stack Overflow的新手,还是VBA编程的新手,所以希望我做对了。

© www.soinside.com 2019 - 2024. All rights reserved.