返回列表 上一主題 發帖

[發問] 抓取參照頁面的 sheet 名稱

回復 3# Genie

自定義函數
  1. Function LocationName(Fn As Range, Rng As Range, item_name As Integer) As String
  2. Dim A As Range
  3. For Each sh In Sheets
  4.   With sh
  5.   If sh.Name <> ActiveSheet.Name Then
  6.   Set A = .Range(Rng.Address(, , xlA1)).Find(Fn)
  7.   If Not A Is Nothing Then
  8.     Select Case item_name 'item_name=0傳回工作表名稱,item_name=1傳回儲存格位址
  9.     Case 0
  10.     LocationName = .Name
  11.     Case 1
  12.     LocationName = A.AddressLocal
  13.     End Select
  14.     Set A = Nothing
  15.     Exit For
  16.   End If
  17.   End If
  18. End With
  19. Next
  20. End Function
複製代碼
SheetName.zip (10.27 KB)
學海無涯_不恥下問

TOP

回復 6# Genie

找到a欄對應的儲存格
學海無涯_不恥下問

TOP

回復 8# Genie

此函數是在範圍中找到你要的資料後,傳回該資料的工作表名稱或是儲存格位址
所以,=LocationName(A2,$A$1:$A$100,0)
一樣可以傳回第一個找到資料的工作表
假如欄位不確定在A攔,可改為=LocationName(A2,$A$1:$B$100,0)
只要範圍內有出現該item就能傳回工作表名稱才對
如果仍然無法達到你的需求,請上傳你出錯的檔案並說明你的需求
學海無涯_不恥下問

TOP

        靜思自在 : 時時好心就是時時好日。
返回列表 上一主題