Search code examples
vbaexcelexcel-2013

Pair Column A & B, get the matching results in C and the difference in D


I have columns "Manifesto A" and "Manifesto B" (with its correspondent volumes) that I get from my SQL Server 2008 DB. A has aprox. 1000 lines and B (and Volumes C) around 800, so it's almost impossible to compare they by hand.
Column "Manifesto C" must have the results of the A>B matching and pairing, and add blank cells where there is no match, as this image example shows.

I've tried this, this, and some SQL CASE WHEN. I don't know VBA, but I'll copy paste anything if you say so.

Can anyone help me sort this out?
Thx in advance! =)


Solution

  • If I understand it correctly, you already have the data, you only need to pair it in Excel?
    If so, suppose you have your data like below:

    enter image description here

    Use this formula in G3:
    =IF(NOT(ISERROR(MATCH(B3,D$3:D$17,0))),B3,"")

    And this formula in H3:
    =IFERROR(VLOOKUP(G3,D$2:E$17,2,0),"")

    Copy it to the rest of the cells.
    For some reason, I don't know why your image didn't show up the result for 32490 and 32563 which are both present in Manifesto A and B. HTH.