在以下兩種方式:功能沒有返回龍
MsgBox find_row(ws_month, bs, cat, subcat, item)
or
dim row as long
row = find_row(ws_month, bs, cat, subcat, item)
MsgBox row
輸出這些代碼
Function find_row(ws As Worksheet, bs As String, _
cat As String, subcat As String, item As String) As Long
Dim vArr As Variant
Dim iCount As Long
Dim lr As Long
Dim tmp As Long
lr = get_last_row(ws)
vArr = Range("a1:d" & lr).Value
For iCount = LBound(vArr) To UBound(vArr)
If vArr(iCount, 1) = bs Then
If vArr(iCount, 2) = cat Then
If vArr(iCount, 3) = subcat Then
If vArr(iCount, 4) = item Then
'MsgBox iCount
tmp = iCount
End If
End If
End If
End If
Next iCount
fing_row = tmp
End Function
返回0
我有輸出的所有變種即將進行功能證明有效數據正在進入,但仍然0
我也可以打印iCount和tmp從withi通過使用消息框功能,但可以返回到我的主代碼的價值?
任何想法?
我在此代碼做不同的唯一的代碼我通常使用的是另外LBOUND和UBOUND的,但我已經檢查了許多實例,並且我相信我有部分權
同時用'Range(「a1」)替換'Range(「a1:d」&lr).Value'。Resize(lr,4).Value' – ja72