Using TODAY in a COUNTIFS formula

spicerguy

New Member
Joined
Sep 20, 2012
Messages
9
Hi,

I have a list of dates in column A, A1:A365 starting at 1/jan/2012 and ending at the end of the year.
In column B I have an activity marker (text string, "Activity", although this can have other text as well) on various dates and empty cells against dates with no activity.

What I would like to do is have a counter for all the activity in the current month using a single cell formula. I've tried variations on the formula below but whenever I try to use a variation of the "today" call in a formula I get a zero count and have to end up using a reference cell which I have to update every month, which is less than ideal.

The formula I've been trying to get to work with various permutations is in the format

=COUNTIFS(B1:B365,"*",A1:A365,"=MONTH(TODAY())")

Which isn't working for me.

I'm using Excel 2010 on win7.

Any help gratefully received by this board newbie.
 

Excel Facts

How to fill five years of quarters?
Type 1Q-2023 in a cell. Grab the fill handle and drag down or right. After 4Q-2023, Excel will jump to 1Q-2024. Dash can be any character.
Could you not have the TODAY function in a different cell and LOOKUP that cell in the COUNTIFS formula?
 
Upvote 0
try this: =SUMPRODUCT(--(MONTH(A1:A365)=MONTH(TODAY())),--((B1:B365)<>""))


SUMPRODUCT multiplies and sums two arrays. The first section MONTH(A1:A365)=MONTH(TODAY()) extracts your date array, compares it to the current month which gives an arrange of False (not in this month) and True (in this month). The double negative here: --(MONTH(A1:A365)=MONTH(TODAY())) converts the TRUE/FALSE values to 1 or 0. The second part of the SUMPRODUCT --((B1:B365)<>"")does something similar but checks that there is something in the cells.

Hope this helps.

Regards
 
Last edited:
Upvote 0
Simon - thanks for this suggestion, I can see how that would work but still relies on a reference cell. However it's certainly better than what I was using before.

Peter - I've tried this out and it works like a charm. Thank you very much! I'll go and apply it within the workbook I'm doing (which is a little more complex than the example) and then also try and figure out why it works - I'm keen to up my excel chops and not just be a cut&paste kid.
 
Upvote 0
My pleasure. To examine how its working use the Evaluate Formula option on the Formula ribbon, it allows you to decompose the formula and see intermediate results.
 
Upvote 0
Just an additional question,

I have an additional column with numeric values (column C, C1:C365). These only occur on rows with Activity (ie, cell content in column B), and I would like to do a calculation to sum these numeric values in the current month. I know this is outside of the scope of the thread header, should I post it as a new thread or are people happy to post a reply in this thread? Hopefully the context of the above will provide enough detail.

Many thanks!
 
Upvote 0
You can just add the range to sum in to SUMPRODUCT, e.g. building on Peter's suggestion

=SUMPRODUCT(--(MONTH(A1:A365)=MONTH(TODAY())),--(B1:B365<>""),C1:C365)

Note that doesn't check the year so I'm assuming you only have data within the current year.

You could also use SUMIFS

=SUMIFS(C1:C365,B1:B365,"<>",A1:A365,">="&EOMONTH(TODAY(),-1)+1,A1:A365,"<"&EOMONTH(TODAY(),0)+1)
 
Upvote 0
Many thanks Barry, the first option works well for me - thanks for the year caveat as well, your assumption is correct but worth being aware of for future reference.

Thanks to everyone who took the time to help out and those who pointed me to other resources as well.
 
Upvote 0

Forum statistics

Threads
1,216,000
Messages
6,128,204
Members
449,435
Latest member
Jahmia0616

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