當前位置:成語大全網 - 新華字典 - VBA用三種方法實現類似vlookup函數功能

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