Excel 請問如何用VB實現vlookup功能
Function mylookup(ByVal lookup_value, table_array As Range, col_index_num%, Optional ByVal range_lookup As Boolean = True) Dim i% With table_array If range_lookup Then i = .Rows.Count Do While .Cells(i, 1) > lookup_value i = i - 1 If i = 0 Then Exit Do Loop If i = 0 Then mylookup = "nothing is found" Else mylookup = .Cells(i, col_index_num) End If Else For i = 1 To .Rows.Count If .Cells(i, 1) = lookup_value Then mylookup = .Cells(i, col_index_num) Exit Function End If Next mylookup = "nothing is found" End If End WithEnd Function