ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Compare Two Columns (https://www.excelbanter.com/excel-programming/434052-compare-two-columns.html)

ng6971

Compare Two Columns
 
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.

smartin

Compare Two Columns
 
ng6971 wrote:
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 the

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.

ng6971

Compare Two Columns
 
Hi Smartin,

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

Thanks & Warm Regards

NG


"smartin" wrote:

ng6971 wrote:
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 the

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.


smartin

Compare Two Columns
 
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 ... ?

ng6971 wrote:
Hi Smartin,

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

Thanks & Warm Regards

NG


"smartin" wrote:

ng6971 wrote:
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 the

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.



All times are GMT +1. The time now is 10:05 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com