COUNTIF using range from TEXT

johnjensen75

New Member
Joined
Aug 22, 2022
Messages
3
Office Version
  1. 365
Platform
  1. Windows
Using this format I am able to pull a single month in text format from a date such as 01/01/2022.
I am trying to do a COUNTIF in a date range in that format, but by searching by the month, example "February"
=(TEXT(A2,"MMMM"))

my date range is in A, my month is in C1
=COUNTIF((text(A:A,"mmmm")),C1)

I realize it would be easier to just add a month only collumn, but this is for my supervisor and not allowed to change the sheet.

Any help would be appreciated, thanks.
 

Attachments

  • Screenshot 2022-08-22 122623.png
    Screenshot 2022-08-22 122623.png
    6.9 KB · Views: 3

Excel Facts

Is there a shortcut key for strikethrough?
Ctrl+S is used for Save. Ctrl+5 is used for Strikethrough. Why Ctrl+5? When you use hashmarks to count |||| is 4, strike through to mean 5.
Upvote 0
Joe4 is right, but if you are really constrained in your solution - this will work. However it's really slow with A:A. If you could limit that substantially, it would be better.

MrExcelPlayground11.xlsx
ABCDE
11/15/2022January2
22/18/2022
33/4/2022
42/20/2022
51/5/2022
Sheet14
Cell Formulas
RangeFormula
E1E1=SUMPRODUCT(--(TEXT(A:A,"mmmm")=C1),--(A:A<>""))
 
Upvote 0
Joe4 is right, but if you are really constrained in your solution - this will work. However it's really slow with A:A. If you could limit that substantially, it would be better.

MrExcelPlayground11.xlsx
ABCDE
11/15/2022January2
22/18/2022
33/4/2022
42/20/2022
51/5/2022
Sheet14
Cell Formulas
RangeFormula
E1E1=SUMPRODUCT(--(TEXT(A:A,"mmmm")=C1),--(A:A<>""))
that worked very well, thanks.
 
Upvote 0
Joe4 is right, but if you are really constrained in your solution - this will work. However it's really slow with A:A. If you could limit that substantially, it would be better.
could you please explain that formula a little for me?
 
Upvote 0
sumproduct is old-school for a 365 user - but it deals with a function on the input range better... it would also be a bit easier if you could put "2" in C1, instead of "February" - but...

It converts column A into a sequence of month texts. If you could make it A2:A1000 or something, instead of all of A:A - it would go much much faster when you update.
Then it checks if that text = C1. You already knew all of this.

So what you'll get is a sequence of TRUE; FALSE; TRUE; TRUE; FALSE;... with that part of the expression. So, in excel, when you do math on TRUE or FALSE, it turns into 1 or 0. So adding zero, or multiplying by 1 or in this case multiplying by -1 twice ("--") turns all of those TRUEs and FALSEs to 1;0;1;1;0. It's summing that up.

The second expression deals with the blanks in column A. If there is nothing in a cell in column A, the TEXT function will take it as January 0, 1900 and return a long list of "January"s - artificially adding to your January count. So I have it zero out the blank cells with the --(A:A<>"") line, so multiplying the fake 1's from the blanks by 0.

I might do something with a LET statement if it was my sheet.
MrExcelPlayground11.xlsx
ABCDE
11/15/2022February2
22/18/2022
33/4/2022
42/20/2022
51/5/2022
Sheet14
Cell Formulas
RangeFormula
E1E1=LET(a,IF(A1:A1000<>"",TEXT(A1:A1000,"mmmm"),0),SUM(IF(a=C1,1,0)))
 
Upvote 0

Forum statistics

Threads
1,215,764
Messages
6,126,749
Members
449,335
Latest member
Tanne

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