How good/fast is Excel VBA’s Find vs. binary search? My platform is Office 11|2003 and I’ll be searching for strings against Column A on three sheets of values. Total number of rows ~140,000
If worth it which Library & functions should I reference to do the sorting and then the binary search? Binary searching strings/text reportedly has potential problems.
… one thing
must be noted. Using binary search
formulas with sortedtextrequires
caution. Aladin A., Excel MVP
Excel Find:
Worksheets(1).Range("A:A").Find("PN-String-K9", LookIn:=xlValues, LookAt:=xlWhole)
Much against my intuition a VBA binary search strongly outperforms an Excel Find. At least with the scenario below where 120,000 6 character strings are distributed evenly over 3 worksheets.
Excel Find takes 1 minute 58 seconds,
VBA binary search takes 36 seconds on my particular machine.
The advantage of knowing that the text is in order obviously outweighs Excel’s natural advantage. Note Aladin A’s warning about sort order.