Compare Two Lists

nniedzielski

Well-known Member
Joined
Jan 8, 2016
Messages
598
Office Version
  1. 2019
Platform
  1. Windows
I am using V Lookup to compare two lists:

VBA Code:
Range("D2").Formula = "=VLOOKUP(B2,'Yard Check'!A:C,3,FALSE)"

I am having a few issues with the comparing of the lists, I have two lists where sometimes the trailer numbers can vary enough to throw off the formula, and I'm wondering how I can code so the Macro finds the trailers to be the same:

Examples:

List A List B
C53106 53106
E001 1
JM122 122
58672S 58672
UMXU830389 830389

Right now when we run the VLookup its returning #N/A, but they are actually the same, how can I get excel VBA to recognize that these are the same? I have tried using "True" instead of "False" but found that didn't really solve the problem.

thank you,
 
It is the same problem reviewed in post #14, your excel version does not support the length of the array formula to pass it from vba to the cell.
It is a limitation of excel.
Suggestions:
- You could put the 2 lists on the same sheet, that saves the space of the name sheet.
- Use the formula from post #27 and copy down.
 
Upvote 0

Excel Facts

Which lookup functions find a value equal or greater than the lookup value?
MATCH uses -1 to find larger value (lookup table must be sorted ZA). XLOOKUP uses 1 to find values greater and does not need to be sorted.
I could use the formula from 27, but I need it to look at the whole column A and C, right now they are just looking at 2:6
 
Upvote 0
When I alter the formula from #27, it appears to find the wrong trailers, maybe the formula is finding wrong numbers too easily now?
 
Upvote 0
It is not recommended to use the entire column in an array formula.

Try

{=IFERROR(INDEX(Yard!$C$2:$C$600,SUMPRODUCT((IF(--ISNUMBER(FIND(Yard!$A$2:$A$600,B7)),LEN(Yard!$A$2:$A$600))=(MAX(IF(--ISNUMBER(FIND(Yard!$A$2:$A$600,B7)),LEN(Yard!$A$2:$A$600)))))*(ROW(Yard!$A$2:$A$600)))-1),VLOOKUP("*"&B7&"*",Yard!$A$2:$C$600,3,0))}

It may be convenient to create a macro that performs searches.
 
Upvote 0
Help me understand how the array works then please, I have a column of 1032 cells that need to be searched. If the array doesn’t catch everything, how do they get found?
 
Upvote 0
Change 600 to a larger number, for example 2000

{=IFERROR(INDEX(Yard!$C$2:$C$2000,SUMPRODUCT((IF(--ISNUMBER(FIND(Yard!$A$2:$A$2000,B7)),LEN(Yard!$A$2:$A$2000))=(MAX(IF(--ISNUMBER(FIND(Yard!$A$2:$A$2000,B7)),LEN(Yard!$A$2:$A$2000)))))*(ROW(Yard!$A$2:$A$2000)))-1),VLOOKUP("*"&B7&"*",Yard!$A$2:$C$2000,3,0))}
 
Upvote 0
Change 600 to a larger number, for example 2000

{=IFERROR(INDEX(Yard!$C$2:$C$2000,SUMPRODUCT((IF(--ISNUMBER(FIND(Yard!$A$2:$A$2000,B7)),LEN(Yard!$A$2:$A$2000))=(MAX(IF(--ISNUMBER(FIND(Yard!$A$2:$A$2000,B7)),LEN(Yard!$A$2:$A$2000)))))*(ROW(Yard!$A$2:$A$2000)))-1),VLOOKUP("*"&B7&"*",Yard!$A$2:$C$2000,3,0))}
I just went through the 1032 lines and this formula does exactly what i need. I was wondering, i get some #N/A results, which just means the value is not on the Yard list, can we alter the formula to return the value "Kill" instead of #N/A?

thanks again,
 
Upvote 0
Try (No tested)

{=IFERROR(IFERROR(INDEX(Yard!$C$2:$C$2000,SUMPRODUCT((IF(--ISNUMBER(FIND(Yard!$A$2:$A$2000,B7)),LEN(Yard!$A$2:$A$2000))=(MAX(IF(--ISNUMBER(FIND(Yard!$A$2:$A$2000,B7)),LEN(Yard!$A$2:$A$2000)))))*(ROW(Yard!$A$2:$A$2000)))-1),VLOOKUP("*"&B7&"*",Yard!$A$2:$C$2000,3,0)), "Kill")}
 
Upvote 0
Press CTRL+SHIFT+ENTER to enter array formulas surrounded with curly braces.
 
Upvote 0

Forum statistics

Threads
1,215,247
Messages
6,123,857
Members
449,129
Latest member
krishnamadison

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