I'd need more detail to be sure, but this sounds like a job for some
VLOOKUP formulae rather than VBA. Can you give us more detail of how the
dat is structured? And of the 40,000 entries on the second sheet, are
the other 36,000 duplicates of the 4,000 on the first, or are they just
other non-matches?