Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/excel/28.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Excel 从选定范围中提取工作表名称_Excel_Worksheet_Inputbox_Vba - Fatal编程技术网

Excel 从选定范围中提取工作表名称

Excel 从选定范围中提取工作表名称,excel,worksheet,inputbox,vba,Excel,Worksheet,Inputbox,Vba,我必须通过InputBox功能在所选单元格中输入结果: Set OutputStrt = Application.InputBox("Select a cell, where the output should be dropped.", "Output start cell", Type:=8) 当我在不同的工作表中运行代码并希望在不同的工作表中得到结果时,它会将结果放在我最初运行代码的工作表中 如何获取通过Application.InputBox选择的工作表名称 例如,当我在输入框中选择:

我必须通过InputBox功能在所选单元格中输入结果:

Set OutputStrt = Application.InputBox("Select a cell, where the output should be dropped.", "Output start cell", Type:=8)
当我在不同的工作表中运行代码并希望在不同的工作表中得到结果时,它会将结果放在我最初运行代码的工作表中

如何获取通过Application.InputBox选择的工作表名称

例如,当我在输入框中选择:定义$F$38如何获得“定义”名称?

试试这个:

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

您也可以使用选择调用它

Dim ws As Workseet
Set ws = Selection.Worksheet
Debug.Print "Sheetname: " & ws.Name

OutputStrt.Parent.Name
谢谢。名字是我需要的,我也有同样的问题。谢谢你的回答。如果您选择另一个工作簿,似乎不必指定它@法迪