Vlookup and countif

LittleStalky

New Member
Joined
Apr 19, 2011
Messages
14
Hi,

I'm trying to pull through data from one sheet into my main sheet using a combination of the vlookup and countif functions. What I'm trying to do is use the vlookup function to find a match in my second sheet, and then pull through a count for however many times "CIF" appears in the columns. For example:

Sheet 1
ABC
1IDNameCIF count
2123Bob3
3456John1
4789Jane0

<tbody>
</tbody>

Sheet 2
ABCDE
1ID2016201520142013
2123CIFCIFCIF
3456CIF
4789

<tbody>
</tbody>

I'm currently using this formula - =IF(ISERROR(VLOOKUP(A2,Summit!A:BH,60,FALSE)),"0",COUNTIF(Summit!2:2,"CIF"))This seems to work fine assuming that the data in sheet 2 remains in the same order. If I sort the data then the results in sheet 1 get all out of whack, which I can see is because the formula is then referencing the wrong cell.

Is there a way I can pull this data through and still be able to sort data in both sheets? Am I going about this completely the wrong way? All of my ID numbers are 100% unique so I thought I'd be able to count the corresponding data based on a match via vlookup.

I'm using Excel 2013 on Windows 8.

Any help would be greatly appreciated.

Thanks

Sarah
 

Excel Facts

Move date out one month or year
Use =EDATE(A2,1) for one month later. Use EDATE(A2,12) for one year later.
A
B
C
D
E
1
IDNameCIF countsheet1
2
123​
Bob
3​
3
456​
John
1​
4
789​
Jane
0​

<tbody>
</tbody>






A
B
C
D
E
F
G
H
1
1​
ID
2016​
2015​
2014​
2013​
sheet2
2
2​
123​
CIFCIFCIF
3
3​
456​
CIF
4
4​
789​

<tbody>
</tbody>


sheet1


c2 =SUMPRODUCT((Sheet2!$B$2:$B$4=Sheet1!$A2)*(Sheet2!$C$2:$F$4=Sheet2!$D$2)) copy down
 
Upvote 0
Thank you so much! This works wonderfully.

A
B
C
D
E
1
IDNameCIF countsheet1
2
123​
Bob
3​
3
456​
John
1​
4
789​
Jane
0​

<tbody>
</tbody>






A
B
C
D
E
F
G
H
1
1​
ID
2016​
2015​
2014​
2013​
sheet2
2
2​
123​
CIFCIFCIF
3
3​
456​
CIF
4
4​
789​

<tbody>
</tbody>


sheet1


c2 =SUMPRODUCT((Sheet2!$B$2:$B$4=Sheet1!$A2)*(Sheet2!$C$2:$F$4=Sheet2!$D$2)) copy down
 
Upvote 0

Forum statistics

Threads
1,215,403
Messages
6,124,710
Members
449,182
Latest member
mrlanc20

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