CountIf

Noz2k

Well-known Member
Joined
Mar 15, 2011
Messages
693
Ok so, I have a column which counts the amount of times an id number appears in a table on sheet 2.

Code:
 =COUNTIF(Sheet2!$A$2:$A$1458,LostCustom!$A2)

but I want to add a further clause to this, which says to only count if the date in column d on sheet 2 is before the 15/03/2011.

Am struggling to get this to work, so any help would be appreciated.
 

Excel Facts

How to calculate loan payments in Excel?
Use the PMT function: =PMT(5%/12,60,-25000) is for a $25,000 loan, 5% annual interest, 60 month loan.
Ok so, I have a column which counts the amount of times an id number appears in a table on sheet 2.

Code:
 =COUNTIF(Sheet2!$A$2:$A$1458,LostCustom!$A2)

but I want to add a further clause to this, which says to only count if the date in column d on sheet 2 is before the 15/03/2011.

Am struggling to get this to work, so any help would be appreciated.

You need a different function which can process multiple conditions...

On Excel 2007 or later:

=COUNTIFS(Sheet2!$A$2:$A$1458,LostCustom!$A2,Sheet2!$D$2:$D$1458,DATE(2011,3,15))

On all versions:

=SUMPRODUCT(--(Sheet2!$A$2:$A$1458=LostCustom!$A2),--(Sheet2!$D$2:$D$1458=DATE(2011,3,15)))
 
Upvote 0
Hi

Depending on your version of Excel:

2007 or above:

=COUNTIFS(Sheet2!$D$2:$D$1458,"<" & DATE(2011,3,15),Sheet2!$A$2:$A$1458,LostCustom!$A2)

2003 or below:

=SUMPRODUCT((Sheet2!$D$2:$D$1458<DATE(2011,3,15))+0,(Sheet2!$A$2:$A$1458=LostCustom!$A2)+0)
 
Upvote 0
Thanks, I was trying to use CountIfs, but wasn't using 'Date' was just trying <15/03/2011.

Your way works perfect though, thanks both of you for your help
 
Upvote 0

Forum statistics

Threads
1,224,607
Messages
6,179,871
Members
452,948
Latest member
UsmanAli786

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