Matching then merging data...

HookEm

Board Regular
Joined
Jun 26, 2002
Messages
85
I hate asking this because I know I will feel dumb when I see the answer but here goes:
I have data in 2 worksheets of 1 workbook. Column B of each worksheet contains the data that I want to match. Wherever there are rows with a match in the B column of each, I want to pull the data from Sheet 2, Column D, and merge it into Sheet 1, Column F. Hope I explained this well enough for someone to help.
Thanks.
 

Excel Facts

Who is Mr Spreadsheet?
Author John Walkenbach was Mr Spreadsheet until his retirement in June 2019.

Travis

Well-known Member
Joined
Feb 26, 2002
Messages
1,711
will an if statement work? put this in column F on Sheet1
=IF(B1=Sheet2!B1,Sheet2!D1,"")

If that is too simple, then possibly a vlookup. In column F on Sheet1 put
=VLOOKUP(B1,Sheet2!B1:D30,3,FALSE)
 

HookEm

Board Regular
Joined
Jun 26, 2002
Messages
85
Not sure... even though column B contains data that can be matched (came from the same field in a database), it is not on the same rows.
 

Travis

Well-known Member
Joined
Feb 26, 2002
Messages
1,711
If each record in column B only appears once, then the vlookup should work (even if they are not in the same order. The example below only picks the first 30 rows, just expand it to get all your data on sheet2. Hope that helps...
=VLOOKUP(B1,Sheet2!$B$1:$D$30,3,FALSE)

again, put this in F1 on sheet 1
 

HookEm

Board Regular
Joined
Jun 26, 2002
Messages
85

ADVERTISEMENT

Here I go again -
I get a #N/A when I enter that. Don't I have to do something to a formula in Excel when it has VBA in it?
 

HookEm

Board Regular
Joined
Jun 26, 2002
Messages
85
Travis,
Found the problem and it works perfectly. Thanks a million for the help.

HookEm
 

HookEm

Board Regular
Joined
Jun 26, 2002
Messages
85
I spoke too soon. This got over half of them but I don't really understand why it did not get the rest. Anybody got a better way of doing this?
 

Travis

Well-known Member
Joined
Feb 26, 2002
Messages
1,711
My last thought...make sure you have the dollar signs in the range of sheet two, so it stays constant when you copy it down. Also the example formula only searched the first 30 rows of sheet2. Change the $D$30 to go through your last row. If you did both of those, then I'm at a loss...If one is formatted as a number and one is a number formatted as text, that could cause a problem also...
 

Forum statistics

Threads
1,143,915
Messages
5,721,512
Members
422,369
Latest member
redinator

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top