Countif speed, Excel 2007 200,000 rows

Jeffrey Green

Well-known Member
Joined
Oct 24, 2007
Messages
1,021
I have to worksheets, each with about 200,000 rows.

I only need to know if a VIN on sheet 1 lives on sheet 2. maybe 195,000 of the rows in sheet 1 do live in sheet two, so I can delete them.

I named the VIN column on Sheet 2 "VIN", and added a column B on sheet 1 and used =Countif(VIN,A2). If it is a 1, I can delete the row, if it is a 0, i need to leave it.


It takes about 45 minutes to do this . . . is there a faster way to simply identify the VINs on sheet 1 that live on Sheet 2??

Thanks
 

Excel Facts

Copy PDF to Excel
Select data in PDF. Paste to Microsoft Word. Copy from Word and paste to Excel.
I have to worksheets, each with about 200,000 rows.

I only need to know if a VIN on sheet 1 lives on sheet 2. maybe 195,000 of the rows in sheet 1 do live in sheet two, so I can delete them.

I named the VIN column on Sheet 2 "VIN", and added a column B on sheet 1 and used =Countif(VIN,A2). If it is a 1, I can delete the row, if it is a 0, i need to leave it.


It takes about 45 minutes to do this . . . is there a faster way to simply identify the VINs on sheet 1 that live on Sheet 2??

Thanks

Try...

=MATCH(A2,VIN,0)

Then activate AutoFilter with the Custom option of Greater than 0. And delete the selected records.
 
Upvote 0
Have you tried using the MATCH function with match_type set to 0? You would then keep the #N/As (if I follow correctly).

Matty
 
Upvote 0
Jeffrey,

Just curious but:

1. How long does it take to do your 200,000 rows with most recent procedure.

2. What is VIN? Vehicle Identification Number, I would guess.
 
Last edited:
Upvote 0
If you want to go really fast, make Excel cheat for you if you can have the VIN be sorted.
=if(VLOOKUP(A2,VIN,1,TRUE)=A2,VLOOKUP(A2,VIN,1,TRUE),"")

This works SO MUCH FASTER when you set vlookup (or match) to be an approximate match, then verify it is your exact match, then display your "approximate" match that you verified. I don't know why, but it took me from about 90 minutes in a large work book (87,000 records, but also around 42 columns to lookup) to about 2 minutes. Not bad eh?
 
Upvote 0
If you want to go really fast, make Excel cheat for you if you can have the VIN be sorted.
=if(VLOOKUP(A2,VIN,1,TRUE)=A2,VLOOKUP(A2,VIN,1,TRUE),"")

This works SO MUCH FASTER when you set vlookup (or match) to be an approximate match, then verify it is your exact match, then display your "approximate" match that you verified. I don't know why, but it took me from about 90 minutes in a large work book (87,000 records, but also around 42 columns to lookup) to about 2 minutes. Not bad eh?

The reason is the algorithm LOOKUP and kindired functions with match-type set to TRUE (or 1) recruit. It must be a variant of binary search.
 
Upvote 0

Forum statistics

Threads
1,224,527
Messages
6,179,331
Members
452,907
Latest member
Roland Deschain

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