# Count unique numbers based on date range and another column of data

##### Active Member
I have the following code in F5 that looks at the EVENT date and checks if each row is in the date range (F:G), then counts each unique ID number and this works great.

However, I now want to add another check to this, which is if the "check days" (D) is >=5 it should ignore that row (ID) (or <5 it should count it) the same as the date period

I have tried adding ,D2:D5, "<5" to the COUNTIFS criteria but I get a #DIV/0 error or it decimalises the count.
How can I add in the extra check, so it checks the date period and days are <5, then counts the unique IDs?

Excel 2010
ABCDEFG
1IDDATEEVENTCHECK (days)fromto
22344513/10/201814/10/2018101/10/201831/12/2018
3314/10/201815/11/201832
4315/10/201821/10/20186Quarter_ID_COUNT
5316/10/201820/10/201842
NEO1
Cell Formulas
RangeFormula
D2=DATEDIF(B2,C2,"d")
F5{=SUMPRODUCT(IF((C2:C5<=G2)*(C2:C5>=F2), 1/COUNTIFS(C2:C5, "<="&G2, C2:C5, ">="&F2, A2:A5, A2:A5), 0))}
Press CTRL+SHIFT+ENTER to enter array formulas.

### Excel Facts

Convert text numbers to real numbers
Select a column containing text numbers. Press Alt+D E F to quickly convert text to numbers. Faster than "Convert to Number"
Try one of these array formulas that must be entered with CTRL-SHIFT-ENTER.
Formula in F5 will work if ID column is either text or numeric. Formula in F7 is shorter, but will only work if ID column is numeric.
Excel Workbook
ABCDEFG
1IDDATEEVENTCHECK (days)fromto
22344510/13/201810/14/2018110/1/201812/31/2018
3310/14/201811/15/201832
4310/15/201810/21/20186Quarter_ID_COUNT
5310/16/201810/20/201842if ID text
6
72if ID numeric
Sheet

Works perfect. Thank you for this.

You're welcome. Thanks for the feedback.

Replies
4
Views
113
Replies
3
Views
55
Replies
3
Views
550
Replies
9
Views
388
Replies
7
Views
116

1,202,908
Messages
6,052,488
Members
444,587
Latest member
ezza59

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