Compare two datasets - VBA array maybe?

TheWennerWoman

Active Member
Joined
Aug 1, 2019
Messages
309
Office Version
  1. 365
Platform
  1. Windows
I have two datasets from two different systems.

Dataset A might look like
Code:
FINEART-MJ I109024
FINEART-MJ I109025
FRANCOLI-PU I109026

Dataset B might look like
Code:
FINEART I109024
FINEART I109025
FRANCOLI I109028

What I need to be able to do is compare dataset A with dataset B and flag anything where the I numbers don't match. I can use LEFT and FIND to tidy dataset A and in the above I would expect the third record to fail (I109026 vs I109028).

There are thousands of these records - I can't use VLOOKUP because it only finds the first record so generates a lot of errors.

Any thoughts appreciated.
 

Excel Facts

Copy a format multiple times
Select a formatted range. Double-click the Format Painter (left side of Home tab). You can paste formatting multiple times. Esc to stop
Hello,

In the formula below, adapt the columns to match your dataset positions, and it should give you the expected result.
With exact datasets (the array does not contain empty rows) :
Excel Formula:
=LET(
  dataA, A2:A4, dataB, B2:B4, 
  GetID, LAMBDA(longN, TAKE(TEXTSPLIT(longN, "I"), , -1)), 
  arrID, HSTACK(BYROW(dataA, GetID), BYROW(dataB, GetID)), 
  FILTER(arrID, CHOOSECOLS(arrID, 1)<>CHOOSECOLS(arrID, 2)))
With potential empty rows :
Excel Formula:
  =LET(
    dataA, A2:A10, dataB, B2:B10, 
    GetID, LAMBDA(longN, TAKE(TEXTSPLIT(longN, "I"), , -1)), 
    arrID, HSTACK(BYROW(dataA, GetID), BYROW(dataB, GetID)), 
    FILTER(arrID, NOT(ISERROR((CHOOSECOLS(arrID, 1))*(CHOOSECOLS(arrID, 1)<>CHOOSECOLS(arrID, 2))))))
 
Upvote 0

Forum statistics

Threads
1,226,478
Messages
6,191,234
Members
453,649
Latest member
jtc19

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