List A/B assumed in cols A and B, with data from row2 down
Leave C1 empty
Select C2:D2, copy down to cover the max expected extent of data in col A,
say, down to D200? Minimize/hide away col C. Col D will return exactly the
results that you seek.