我想基本上做一個VLOOKUP
,但我的單元格的內容過長VLOOKUP
處理。因此,我使用這個VBA腳本通過一個定義的範圍進行搜索:Excel中 - 通過搜索範圍內使用VBA
Function betterSearch(searchCell, Range As String)
For Each cell In Range
If cell.Value = searchCell.Value Then
betterSearch = "Match"
Exit For
End If
betterSearch = "No match"
Next
End Function
該函數被稱爲(例如):=betterSearch(B33;'Master'!C:C)
然而,我不能得到一個輸出。我得到了雙眼,我犯了什麼錯誤?
不應該'範圍作爲字符串'是範圍作爲範圍? – dwirony
您的變量不應該與預先存在的方法具有相同的名稱。 'betterSearch(searchCell,Source As Range)'會更好。 –