【发布时间】:2018-08-02 20:34:29
【问题描述】:
我编写了以下 UDF 函数,如果在指定范围内找到单元格值,则返回 True,否则返回 False:
Function find_in_range(value_to_find As Variant, lookup_range As Range) As Boolean
For Each cell In lookup_range.Cells.SpecialCells(xlConstants)
If cell.Value = value_to_find Then
find_in_range = True
Exit For
Else
find_in_range = False
End If
Next cell
End Function
但是,它比 VLOOKUP 慢得多。
为什么会这样?有没有办法让它更快?用什么魔法让 VLOOKUP 搜索更快?
【问题讨论】: