'Vlookup_each("mp3",A2:A6,B2:B99,2)£¬²éÕÒ·ûºÏÌõ¼þµÄ¶àÌõ¼Ç¼£¬Vlookup_each(Ìõ¼þ,ÅжÏÌõ¼þµÄÇøÓòÌõ¼þ,·ûºÏÌõ¼þÐèÒªÏÔʾµÄÇøÓò,µÚ¼¸Ìõ¼Ç¼) Public Function Vlookup_each(Lookup_value As String, Lookup_vector As Range, Result_vector As Range, K As Integer) If K <= 0 Or (K Mod 1) <> 0 Then Vlookup_each = "#REF!" Exit Function End If Dim cell As Range Dim i As Integer Dim cellrow As Range Dim Arr Arr = WorksheetFunction.Index(Lookup_vector, 0, 1) For Each cell In Arr If cell.Value = Lookup_value Then i = i + 1 If i = K Then Set cellrow = Worksheets(cell.Parent.Name).Range(cell.Row & ":" & cell.Row) Vlookup_each = Intersect(cellrow, Result_vector).Value Exit Function End If End If Next If i = 0 Or K > i Then Vlookup_each = "" End If End Function |