Excel 从选定范围中提取工作表名称
我必须通过InputBox功能在所选单元格中输入结果: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选择的工作表名称 例如,当我在输入框中选择:
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
谢谢。名字是我需要的,我也有同样的问题。谢谢你的回答。如果您选择另一个工作簿,似乎不必指定它@法迪