ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Compare two columns and copy data if values are the same. (https://www.excelbanter.com/excel-programming/423179-compare-two-columns-copy-data-if-values-same.html)

Akhorahil

Compare two columns and copy data if values are the same.
 

I've tried figuring this out with formulas but I think I need a vba
solution.
I've got a column with values in column A in sheet 1 and I've got a
column of values in column G of sheet 2. Every value in column G sheet2
is one of the values from column A sheet 1. What I need is something
that will compare G to the whole column of A and then copy the value
from cell B from sheet 1 to Column H in sheet 2.
Example:

Sheet 1 Sheet 2
A B G H
1 1 1
2 8 1
3 4 2
4 6 4
5 3 4
4
5

Would become

Sheet 2
G H
1 1
1 1
2 8
4 6
4 6
4 6
5 3

Any help would be appreciated.



Akhorahil[_2_]

Compare two columns and copy data if values are the same.
 

Ok the advertisement messed up the layout.
Sheet 1 Sheet 2
A B G H
1 1 1
2 8 1
3 4 2
4 6 4
5 3 5
Would become
Sheet 2
G H
1 1
1 1
2 8
4 6
5 3



Dave Peterson

Compare two columns and copy data if values are the same.
 
It looks like you could use =vlookup() or =index(match())
=vlookup(g1,sheet1!a:b,2,false)

Debra Dalgleish has lots of notes:
http://www.contextures.com/xlFunctions02.html (for =vlookup())
and
http://www.contextures.com/xlFunctions03.html (for =index(match()))
and
http://contextures.com/xlFunctions02.html#Trouble

Akhorahil wrote:

Ok the advertisement messed up the layout.
Sheet 1 Sheet 2
A B G H
1 1 1
2 8 1
3 4 2
4 6 4
5 3 5
Would become
Sheet 2
G H
1 1
1 1
2 8
4 6
5 3


--

Dave Peterson


All times are GMT +1. The time now is 05:28 PM.

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