(若是和其他不同軟體互動之問題 請記得一併填寫)
軟體:excel
版本:2019
Public Function test1(PROD As String) As Integer
Dim wsFunc As WorksheetFunction: Set wsFunc =
Application.WorksheetFunction
Dim ws As Worksheet: Set ws = Sheets("Sheets1")
Dim rngLook As Range: Set rngLook = ws.Range("A1:B10")
Dim target_name As String
Dim value As String
On Error Resume Next
value = wsFunc.VLookup(PROD, rngLook, 2, False)
test1 = value
End Function
一直卡在黃字 陣列索引超出範圍
我是想寫一個變數帶入
如果是 蘋果 值=10
香蕉 值=20
前面會抓一個字串
fruit = 香蕉
Dim retVal As Integer
retVal = test1("fruit")
不知道該怎麼改