2012-09-14 91 views
0

有沒有辦法可以在excel(VBA)中找到函數VLOOKUP的源代碼,所以我可以修改它? Google不給我任何幫助。謝謝!Excel VLOOKUP函數源代碼

回答

-1

VLOOKUP/HLOOKUP更靈活(非VBA)版本,這是一個簡單的實現VLOOKUP的:

 Public Function VLOOKUP1(ByVal lookup_value As String, ByVal table_array As Range, ByVal col_index_num As Integer) As String 
     Dim i As Long 

     For i = 1 To table_array.Rows.Count 
      If lookup_value = table_array.Cells(table_array.Row + i - 1, 1) Then 
       VLOOKUP1 = table_array.Cells(table_array.Row + i - 1, col_index_num) 
       Exit For 
      End If 
     Next i 

     End Function 
0

基於瓦希德的答案,沒有工作對我而言,我做了以下代碼確實有效:

Function CUSTOMVLOOKUP(lookup_value As String, table_array As Range, col_index_num As Integer) 
    Dim i As Long 
    For i = 1 To table_array.Rows.Count 
     If lookup_value = table_array.Cells(i, 1) Then 
      CUSTOMVLOOKUP = table_array.Cells(i, col_index_num) 
      Exit For 
     End If 
    Next i 
End Function