Excel 根據名字獲取另一個sheet中的數據


Public Function GetProduct(company_name, postion)

Set d = CreateObject("scripting.dictionary")
last_B = Sheets("Sheet2").Cells(Rows.Count, 1).End(xlUp).Row
bb = Sheets("Sheet2").Range("B1:C" & last_B)
For i = 2 To UBound(bb)
    If bb(i, 1) = company_name And Not IsEmpty(bb(i, 2)) And Not IsNull(bb(i, 2)) Then
        d(bb(i, 2)) = i
    End If
Next
'On Error GoTo myerr
GetProduct = d.Keys()(postion - 1)
'myerr:
'GetProduct = ""
End Function


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM