Any clever solutions to speed up a 50,000 row MATCH formula?

d0rian

Active Member
Joined
May 30, 2015
Messages
313
Office Version
  1. 365
I have a data set of 50,000 text entries in column A. Every day a few hundred entries are added to the data set, and I paste the NEW set of entries (e.g. let's say a total of 50,275, which includes both the 50,000 from the prior day and 275 new ones) in column B.
I want the fastest way to identify the new 275 entries (which exist in column B, but not A).
The simplest method I know of is to paste a simple MATCH formula in column C, e.g. =IF(ISNUMBER(MATCH(B1,A:A,0)),"","n")
But that takes 10-12 seconds to run on 50,000+ rows.

Can anyone think of any way to accomplish this faster?
 

Excel Facts

Return population for a City
If you have a list of cities in A2:A100, use Data, Geography. Then =A2.Population and copy down.
Sort column A ascending and apply a binary search.
Excel Formula:
 If( Vlookup(B1,a:a,1)=B1, "", "n").
 
Last edited:
Upvote 0
A slight correction to the syntax of @GraH's suggestion.
Excel Formula:
=IF(LOOKUP(B1,A:A)=B1,"n","")
 
Upvote 0
Wow, OK so both of those options work in approx the same time: < 1s. (I assume they're essentially equivalent, but that LOOKUP is slightly preferable for optics / simplicity, since VLOOKUP unnecessary when it's a single-column lookup, and has more parameters.)

MUST col A be sorted alphabetically for this to work properly?
(EDIT: answered my own Q by testing with reverse alpha sort on col A and finding that that does indeed break this...so need to better understand what's going on with this formula, and why sorting is a pre-requisite)

Also, just why does this cut 95% off the calc time...I haven't used LOOKUP in ages, having thought that INDEX/MATCH was far faster/preferable...but why in this instance is LOOKUP so much faster, since there's tons of other places where i want to deploy this...
 
Upvote 0
MUST col A be sorted alphabetically for this to work properly?

Also, just why does this cut 95% off the calc time...I haven't used LOOKUP in ages, having thought that INDEX/MATCH was far faster/preferable...but why in this instance is LOOKUP so much faster, since there's tons of other places where i want to deploy this...
Yes, else the binary lookup does not work correctly.

This is why Linear Search vs Binary Search - GeeksforGeeks
 
Upvote 0
There is also Xlookup (office 365 only) and MATCH / XMATCH (again, office 365 only).

With these functions you can also reverse the sort order, the office 365 functions have a more options, although I don't remember all of them off hand.
 
Upvote 0
There is also Xlookup (office 365 only) and MATCH / XMATCH (again, office 365 only).

With these functions you can also reverse the sort order, the office 365 functions have a more options, although I don't remember all of them off hand.

Maybe I'm misunderstanding, but you mention the MATCH function (which of course exists in all Excel versions) as one that can incorporate binary search methodology....but that's of course the super-slow formula in the OP I started out with that I presume uses linear logic, by default at least. Is there a way to force MATCH to use binary logic? Or did I misunderstand your reply?
 
Upvote 0
Numbers sort before text. So it works on a combination of numbers and text or even mixed strings.
If I'm not mistaken sorting is on the asci code.
 
Upvote 0

Forum statistics

Threads
1,214,975
Messages
6,122,538
Members
449,088
Latest member
RandomExceller01

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top