How to optimize vlookup for high search count ? (alternatives to VLOOKUP)

前端 未结 4 1210
名媛妹妹
名媛妹妹 2020-11-27 15:48

I am looking for alternatives to vlookup, with improved performance within the context of interest.

The context is the following:

  • I have a data set of
4条回答
  •  旧巷少年郎
    2020-11-27 16:11

    You also may want to consider using the “double Vlookup” method (not my idea - seen elsewhere). I tested it on 100,000 lookup values on sheet 2 (randomly sorted) with an identical data set as the one you’ve described on sheet 1, and timed it at just under 4 seconds. The code is also a bit simpler.

    Sub FastestVlookup()
    
        With Sheet2.Range("B1:B100000")
            .FormulaR1C1 = _
            "=IF(VLOOKUP(RC1,Sheet1!R1C1:R100000C1,1)=RC1,VLOOKUP(RC1,Sheet1!R1C1:R100000C2,2),""N/A"")"
            .Value = .Value
        End With
    
    End Sub
    

提交回复
热议问题