vba 从所选范围中提取工作表名称
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/42124612/
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
Extract a worksheet name from the range selected
提问by Sam
I have to input the result in the selected cell through InputBox function:
我必须通过 InputBox 函数在所选单元格中输入结果:
Set OutputStrt = Application.InputBox("Select a cell, where the output should be dropped.", "Output start cell", Type:=8)
When I ran the code in the different worksheet and want the result in the different worksheet, it drops the result in the worksheet where I initially ran the code.
当我在不同的工作表中运行代码并希望在不同的工作表中得到结果时,它会将结果放入我最初运行代码的工作表中。
How do I get the Worksheet name, which I selected through the Application.InputBox ?
如何获取我通过 Application.InputBox 选择的工作表名称?
For example, when I selected in the Inputbox: Definitions!$F$38 how do I get the name 'Definitions'?
例如,当我在输入框中选择:Definitions!$F$38 时,我如何获得名称“Definitions”?
采纳答案by Fadi
Try This:
尝试这个:
Sub test()
Dim Ws As Worksheet
Dim OutputStrt As Range
Set OutputStrt = Application.InputBox("Select a cell, where the output should be dropped.", "Output start cell", Type:=8)
Set Ws = OutputStrt.Worksheet
MsgBox Ws.Name
End Sub