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 With
End Function
for 循环匹配 匹配到后 记录当前行数,然后引用需要的行列号