Using IF AND with the COUNT function

BobbyB88

New Member
Joined
Jun 25, 2015
Messages
3
Hi,

I am currently trying to do a COUNTIFS on a closed sheet. Checking the forums, I have tried splitting the formula into COUNT(IF(, but as I was counting between two dates I need an IFAND. Can't work out how to calculate it

=COUNT(IF(AND('[DOC.xlsm]New'!$F$7:$F$2506,">="&$A$1,'[DOC.xlsm]New'!$F$7:$F$2506,"<="&$B$1),1))

A1 and B1 are the beginning and end date. It began life as the below formula which worked correctly.

=COUNTIFS('[DOC.xlsm]New'!$F:$F,">="&$A$1,'[DOC.xlsm]New'!$F:$F,"<="&$B$1)

Any help, much appreciated :)

Thanks

Rob
 

Excel Facts

Excel motto
Not everything I do at work revolves around Excel. Only the fun parts.
Welcome to the board.

So the issue is that countifs doesn't work on a closed book right?
Try a sumproduct equivelent.

=SUMPRODUCT(--('[DOC.xlsm]New'!$F:$F>=$A$1),--('[DOC.xlsm]New'!$F:$F<=$B$1))

Though I highly recommend NOT using entire column references in sumproduct.
Countif was smart enough to only parse through the actual used range, sumproduct will actually parse every single row.
That creates ALOT of unnecessary calculations on empty rows.
So it's best to define start/end rows in the ranges.
I use the 10% rule of thumb, like in construction.
Use 10% more rows than you think you'll need.
So if your dataset is normally around 5000 rows, use 5500


=SUMPRODUCT(--('[DOC.xlsm]New'!$F$1:$F$5500>=$A$1),--('[DOC.xlsm]New'!$F$1:$F%5500<=$B$1))
 
Upvote 0
Hi,

That was spot on, thankyou. I am trying to understand now how to SUM that product for a further calculation, but seem to be messing up somewhere. Could you take a quick look please?

=SUMPRODUCT(--('[DOC.xlsm]New'!$F$7:$F$2506>=$A$1),--('[DOC.xlsm]New'!$F$7:$F$2506<=$B$1),'[DOC.xlsm]New'!$AA$7:$AA$2506)

The intended sum is column AA, but I cannot see where I have gone wrong :confused:

Cheers

Rob
 
Upvote 0
That apears to be the correct syntax to sum based on the criteria.

did this give the correct COUNT ?
=SUMPRODUCT(--('[DOC.xlsm]New'!$F$7:$F$2506>=$A$1),--('[DOC.xlsm]New'!$F$7:$F$2506<=$B$1))

If that produces the correct 'Count' but the formula you posted doesn't give the correct sum, that would mean
Some or All of the values in Column AA are not really numbers (at least the ones corresponding to the True results of the criteria).


Does this give the correct result (granted it won't work on the closed book, this is just troubleshooting)
=SUMIFS('[DOC.xlsm]New'!$AA$7:$AA$2506,'[DOC.xlsm]New'!$F$7:$F$2506,">="&$A$1,'[DOC.xlsm]New'!$F$7:$F$2506,"<="&$B$1)
 
Upvote 0
Sorry yes, that was my fault, a #N/A outside of the date range that I hadn't spotted.

Thanks for all your help

Have a great day

Rob
 
Upvote 0

Forum statistics

Threads
1,214,822
Messages
6,121,772
Members
449,049
Latest member
greyangel23

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