# countif vlookup greater than date

#### mkofler

##### New Member
Greetings Excel Gods!
I'm trying to find out: For each person (ID #), how many times have they been arrested following a program referral? Each arrest is in a separate row:
For each ID number in Workbook1 (column B), search Workbook2 for each instance of that number. For each instance found in Workbook2, look at the date in column D. If the date in Workbook 2 column D is greater than the date in Workbook1 column AQ, then count it and return the total.

Any help would be greatly appreciated. I was thinking that a vlookup would work, but that only seems to find the first instance.
Thanks!

### Excel Facts

Best way to learn Power Query?
Read M is for (Data) Monkey book by Ken Puls and Miguel Escobar. It is the complete guide to Power Query.

#### just_jon

##### Legend
mkofler said:
Greetings Excel Gods!
I'm trying to find out: For each person (ID #), how many times have they been arrested following a program referral? Each arrest is in a separate row:
For each ID number in Workbook1 (column B), search Workbook2 for each instance of that number. For each instance found in Workbook2, look at the date in column D. If the date in Workbook 2 column D is greater than the date in Workbook1 column AQ, then count it and return the total.

Any help would be greatly appreciated. I was thinking that a vlookup would work, but that only seems to find the first instance.
Thanks!

=SUMPRODUCT(--('[WB2.xls]Sheetname'!\$B\$1:\$B\$1000=B1),--('[WB2.xls]Sheetname'!\$D\$1:\$D\$1000>AQ1))

Where workbook2 column B holds IDs, workbook2 column D holds dates.

L

#### Legacy 51064

##### Guest
I would use the sumproduct formula.

Put this in C1 and copy down

=SUMPRODUCT(('[Workbook2.xls]Sheet1'!\$B\$1:\$B\$5000=B1)*('[Workbook2.xls]Sheet1'!\$D\$1:\$D\$5000>=AQ1))

This is assuming that your ID on Workbook1 are in the B column.

#### mkofler

##### New Member
Sweet!
Thanks to both of y'all.

Replies
3
Views
152
Replies
7
Views
120
Replies
0
Views
402
Replies
1
Views
151
Replies
4
Views
497

1,195,721
Messages
6,011,296
Members
441,600
Latest member
Ramatu

### 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.

### Which adblocker are you using?

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

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