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