Lookup a duplicate value in a table only once

BarKv

New Member
Joined
Jul 23, 2018
Messages
8
I have a dataset consisting of approx 200,000 rows. One of the columns is named ProjectNumber, and if I remove the duplicates there is approx 2,000 unique values left. I have a lookup formula to another table with projects, to check if the ProjectNumber exists. I know how to do the lookup formula itself (using MATCH), but the formula takes 7 seconds to finish up checking every of the 200,000 rows. In comparison, when I remove the duplicates, and check only the 2,000 remaining rows, the formula takes less than 0,1 seconds. (I'm using a RangeTimer macro to measure the time.) So, my worksheet with all the 200,000 rows is very slow :/

I know how to remove the duplicates, but I'm making this sheet for others to use, and I would like an error message to be displayed in the table with the 200,000 rows. I only need one of the rows with a non existing ProjectNumber to display the error message.

So, my question is this: Is there any formula that can do a lookup for the ProjectNumber, but if the same ProjectNumber already has been checked, then the formula should do nothing. So basically, I need a formula that checks a duplicate value only once.

What I have tried:
  • IF(ROW([@ProjectNumber])-1=MATCH([@ProjectNumber],[ProjectNumber],0),"Lookup","Do not lookup")
    This formula only does a lookup if the row number equals the row where the ProjectNumber first appears. However, the MATCH part is doing what I'm trying to avoid in the first place, by checking the entire 200,000 rows, for each row. So, this formula also slows Excel down.

Any ideas? :)
 

Excel Facts

VLOOKUP to Left?
Use =VLOOKUP(A2,CHOOSE({1,2},$Z$1:$Z$99,$Y$1:$Y$99),2,False) to lookup Y values to left of Z values.
I'm not too certain if I understand what you are trying to accomplish. Perhaps you could stop the formula from executing by starting off with a an IF functions that counts the amount of rows, and only when the amount is smaller than x (IF=False), the rest of the formula is executed
 
Last edited:
Upvote 0
Care to post a sample of the data and the output area if it's within the table you seem to have?

I can try. Not sure what you want here, but is this ok?

ProjectNumberCheck if ProjectNumbers exists in another table
1Error: This number does not exist
1Error: This number does not exist
1Error: This number does not exist
1Error: This number does not exist
2
2
2
3Error: This number does not exist
4

<tbody>
</tbody>

So, for all the rows with ProjectNumber=1, I only want to check one of them, and one error message in total for ProjectNumber=1.
 
Upvote 0
I'm not too certain if I understand what you are trying to accomplish. Perhaps you could stop the formula from executing by starting off with a an IF functions that counts the amount of rows, and only when the amount is smaller than x (IF=False), the rest of the formula is executed

I tried a IF(COUNTIF(, but it looks like the COUNTIF also needs to go through every of the 200,000 rows for each row. Is there any way to do a count and stop counting if the count reaches 2 or higher?
 
Upvote 0
I can try. Not sure what you want here, but is this ok?

ProjectNumberCheck if ProjectNumbers exists in another table
1Error: This number does not exist
1Error: This number does not exist
1Error: This number does not exist
1Error: This number does not exist
2
2
2
3Error: This number does not exist
4

<tbody>
</tbody>

So, for all the rows with ProjectNumber=1, I only want to check one of them, and one error message in total for ProjectNumber=1.

Just post what the second column must show...
 
Upvote 0
Sure :)

ProjectNumberCheck if ProjectNumbers exists in another table
1Error: This number does not exist
1
1
1
2
2
2
3Error: This number does not exist
4

<tbody>
</tbody>

In B2 enter and copy down:

=IF(ISNA(MATCH(A2,$A$1:A1,0)),IF(ISNA(VLOOKUP(A2,Table,1,0)),"Error: This number does not exist",""),"")
 
Upvote 0

Forum statistics

Threads
1,214,866
Messages
6,121,996
Members
449,060
Latest member
mtsheetz

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