VLOOKUP to compare 2 spreadsheets?

AdamJones

New Member
Joined
Apr 1, 2016
Messages
9
Hi,

I have to compare 2 sheets for work, they are as follows:

Sheet 1:
Column A: Preferred Site
Column B: Student ID Number
Column C: Surname
Column D: Forename

Sheet 2:
Column A: Allocated Site
Column B: Student ID Number
Column C: Surname
Column D: Forename

I need to find out how many people from sheet 2 were allocated to their preferred site from sheet 1. I've tried using vlookup but the way I'm entering it must be wrong? If I choose the first selection as ID from sheet 2, the range as all columns from sheet 1, then 1, and false?

Can anybody help?

Much Appreciated
 

Excel Facts

Will the fill handle fill 1, 2, 3?
Yes! Type 1 in a cell. Hold down Ctrl while you drag the fill handle.
Control+shift+enter, not just enter:

=SUM(IF(ISNUMBER(MATCH(Sheet2!$B$2:$B$8&"|"&Sheet2!$A$2:$A$8,$B$2:$B$7&"|"&$A$2:$A$7,0)),1))
 
Upvote 0
Thanks that's great, but I also need to see where people where allocated if it wasn't their preference so I think I need vlookup?
 
Upvote 0
Thanks that's great, but I also need to see where people where allocated if it wasn't their preference so I think I need vlookup?

Sheet2

Row\Col
A​
B​
1​
allocated siteid
2​
a
1​
3​
x
2​
4​
b
1​
5​
y
3​
6​
q
7​
7​
c
4​
8​
d
5​

Sheet1


Row\Col
A​
B​
E​
1​
preferred siteid
4​
2​
a
1​
3​
a
2​
x
4​
b
1​
5​
c
3​
y
6​
Q
7​
7​
c
4​

In E4 control+shift+enter, not just enter:
Rich (BB code):
=SUM(IF(ISNUMBER(MATCH(Sheet2!$B$2:$B$8&"|"&Sheet2!$A$2:$A$8,
    $B$2:$B$7&"|"&$A$2:$A$7,0)),1))

This means: For 4 id's the sites allocated to them match the sites they prefer. Given the fact that we have here 6 records, 2 times the expected correspondence do not materialize as displayed below:

In E2 control+shift+enter, not just enter, and copy down:
Rich (BB code):
=IF($B2="","",IF(ISNUMBER(MATCH($A2&"|"&$B2,Sheet2!$A$2:$A$8&"|"&Sheet2!$B$2:$B$8,0)),"",
    INDEX(Sheet2!$A$2:$A$8,MATCH(1,IF(Sheet2!$B$2:$B$8=$B2,IF(1-(Sheet2!$A$2:$A$8=$A2),1)),0))))
 
Upvote 0

Forum statistics

Threads
1,216,083
Messages
6,128,718
Members
449,465
Latest member
TAKLAM

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
Back
Top