COUNTIF issue

mattbird

Active Member
Joined
Oct 15, 2013
Messages
305
Office Version
  1. 2016
I have a table that I want to pull information per quarter ie Apr-Jun, Jul-Aug etc.
In cells A3:A20 I have used Q1, Q2, Q3, Q4 for the quarters.
In cell B3 I have created a list ‘All, Q1, Q2, Q3, Q4’, so I can select which quarter I want.
In cell B5 I have use the following formula to count:
=COUNTIF(A3:A20,B3) which works and provides me with one of the selected text from the list in B3, ie Q2. However, how do I get the formula to count all text A3:A20, if I select ‘All’ from the list at B3?

Can this be done?

Any help or advice is greatly appreciated.

Matt
 

Excel Facts

Workdays for a market open Mon, Wed, Friday?
Yes! Use "0101011" for the weekend argument in NETWORKDAYS.INTL or WORKDAY.INTL. The 7 digits start on Monday. 1 means it is a weekend.
try this:
Excel Formula:
=IF(B3="ALL",COUNT(A3:A20),COUNTIF(A3:A20,B3))
 
Upvote 0
Another option
Excel Formula:
=COUNTIFS(A:A,IF(B3="All","?*",B3))
 
Upvote 0
Another option
Excel Formula:
=COUNTIFS(A:A,IF(B3="All","?*",B3))
Thanks for your help. This works. If B3 is empty it returns a 0, how do I get it to show as blank, if nothing is selected from the list? Would it need an IFERROR?
 
Upvote 0
Thanks for your help. It counts all the Q1,2,3,4 but ‘All’ returns a 0?
I take it you didn't make the suggested modification to awoohaw's submission.
This also adds the blank criteria.
You can do the same think to Fluff's option.
Excel Formula:
        =IF(B3="","",IF(B3="ALL",COUNTA(A3:A20),COUNTIF(A3:A20,B3)))
 
Upvote 0

Forum statistics

Threads
1,214,920
Messages
6,122,264
Members
449,075
Latest member
staticfluids

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