Compare Two Columns

N

ng6971

Hi All,

I have 4 data columns. Column A has 150 data cells, Column B, C and D has
450 data cells.

I would like to compare only Column A to Column B and if there is a match,
put the matching results in Column F - Column G - Column H - Column I.

Situation:
A B C D
1 3 x y
2 2 x y
3 0 x y
4 1 x y


Results needed:
F G H I
1 1 x y
2 2 x y
3 3 x y


Any help would be great!

Thanks in Advance.
 
S

smartin

ng6971 said:
Hi All,

I have 4 data columns. Column A has 150 data cells, Column B, C and D has
450 data cells.

I would like to compare only Column A to Column B and if there is a match,
put the matching results in Column F - Column G - Column H - Column I.

Situation:
A B C D
1 3 x y
2 2 x y
3 0 x y
4 1 x y


Results needed:
F G H I
1 1 x y
2 2 x y
3 3 x y


Any help would be great!

Thanks in Advance.

Assuming values in A will have at most one match in B this boils down to
a VLOOKUP. Do you need to use VBA? If not these worksheet functions will
get you most* of the way there:

F1 =A1
G1 =VLOOKUP(F1,$B$1:$D$450,1,FALSE)
H1 =VLOOKUP(F1,$B$1:$D$450,2,FALSE)
I1 =VLOOKUP(F1,$B$1:$D$450,3,FALSE)

*there may be values in A that have no match in B and will return #N/A.
 
N

ng6971

Hi Smartin,

It Works perfectly. Need a VBA code also for entire columns not the range as
mentioned eariler.

Thanks & Warm Regards

NG
 
S

smartin

I'm a little confused about the requirement. What do you expect a VBA
solution to do that the worksheet function does not do? Do you want to
avoid placing a function in the cells altogether (and which cells are
they? or is the code supposed to figure that out? and what should the
trigger be to run the code?) Or instead do you want a custom function
called from the worksheet? Or ... ?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top