2017-02-08 23 views
1

的範圍內提取工作表名稱我輸入的結果通過InputBox函數選定單元格:從選擇

Set OutputStrt = Application.InputBox("Select a cell, where the output should be dropped.", "Output start cell", Type:=8) 

當我運行的代碼在不同的工作表,並希望在不同的工作表中的結果,它會將結果放在最初運行代碼的工作表中。

如何獲取通過Application.InputBox選擇的工作表名稱?

例如,當我在輸入框中選擇:定義!$ F $ 38如何獲得名稱'定義'?

+1

'OutputStrt.Parent.Name' –

回答

1

試試這個:

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 
+0

謝謝! .Name是我所需要的。 – Sam

+0

不客氣。 – Fadi