vba 如何从 Application.Caller 获取工作表名称?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/16917156/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to get the sheet name from Application.Caller?
提问by Dulini Atapattu
It is possible to get the calling workbook name Application.Caller.Worksheet.Parent.Name
and cell address using Application.Caller.Address
, for a function called in Excel.
对于在 Excel 中调用的函数,可以Application.Caller.Worksheet.Parent.Name
使用Application.Caller.Address
,获取调用工作簿名称和单元格地址。
Is there a way to get the sheet name, e.g. Sheet1, using Application.Caller
?
有没有办法获取工作表名称,例如 Sheet1,使用Application.Caller
?
回答by JosieP
you pretty much had it already
你几乎已经拥有了
Application.Caller.Worksheet.Name
回答by Joh
Dim called_by As Variant
Dim x as string
Set called_by = Application.Caller
x = called_by.Parent.Application.Activesheet.Name
works fine in my application when calling this function within a cell.
在单元格中调用此函数时,在我的应用程序中工作正常。