Count if range contains text within another range

Costtx

New Member
Joined
May 15, 2017
Messages
19
I would like to create a formula which counts data if it matches the criteria layed out in multiple cell ranges.

Range 1 - Region
Central
Far North
Metropolitan
North Coast
North
South

each region will contain these locations among others:
School
High School
Kindergarten
City Hall
Shopping Centre
Health Centre
Hospital
(various other similar locations)

Range 2 - Status
New
Awaiting Approval
Work in Progress
Resolved
Closed

I have a cell for each region and would like to have a formula which counts how many of the locations in each region has a status of new, awaiting approval and work in progress.
I then have a separate cell which counts how many locations in each region has a status of resolved and closed.

I have used the following formulas which have worked in similar counting functions within the same workbook

=SUM(COUNTIFS(Region,"=Central",Status,{"New","Work in Progress","Awaiting Approval"}))

I have tried to tweak it a bit to further so it performs the same function but with specific locations within the region range. I have tried creating a separate range including those specific location, problem is that every time i try it just returns a value of zero.

Any suggestions?

Thanks
 

Excel Facts

How to create a cell-sized chart?
Tiny charts, called Sparklines, were added to Excel 2010. Look for Sparklines on the Insert tab.
What are the lengths of your two ranges (Region and Status)? COUNTIF is expecting that within your data table, the range named Region has some size (probably a start row and end row), and the range named Status should have the same start and end points. Then COUNTIF will examine which rows/columns satisfy all of the matching criteria. I see no issue with your formula in red (you could eliminate the = sign "Central" rather than "=Central", but that is minor. I suspect the issue is how the named ranges are being used.

As an experiment, try substituting explicit cell ranges with equal start and end points for Region and Status...for example:
=SUM(COUNTIFS(A2:A10,"Central",D2:D10,{"New","Work in Progress","Awaiting Approval"}))
...or whatever cell references hold the relevant content.

Also, what version of Excel are you using?
 
Upvote 0
What are the lengths of your two ranges (Region and Status)? COUNTIF is expecting that within your data table, the range named Region has some size (probably a start row and end row), and the range named Status should have the same start and end points. Then COUNTIF will examine which rows/columns satisfy all of the matching criteria. I see no issue with your formula in red (you could eliminate the = sign "Central" rather than "=Central", but that is minor. I suspect the issue is how the named ranges are being used.

As an experiment, try substituting explicit cell ranges with equal start and end points for Region and Status...for example:
=SUM(COUNTIFS(A2:A10,"Central",D2:D10,{"New","Work in Progress","Awaiting Approval"}))
...or whatever cell references hold the relevant content.

Also, what version of Excel are you using?

Hey KRice,

Thank you for the advice. I tried the explicit cell ranges, and it didn't work for me. I am using excel 2016.
 
Upvote 0
Could you post a small portion of your worksheet to illustrate the issue, ideally using XL2BB?...something like this:
Book1
BCDE
1
2Count
3ANew 2
4BNew
5AReview
6BOld
7BNew
8BReview
Sheet4
Cell Formulas
RangeFormula
E3E3=SUM(COUNTIFS($B$3:$B$8,"B",$C$3:$C$8,{"Review","Old"}))
 
Upvote 0
Hi Kirk,

As requested:
1588915764464.png
1588916200163.png


Formula of C6 (Functioning as it should)
=SUM(COUNTIFS(Region,"Central",Status,{"New","Work in Progress","Customer Replied","Awaiting Customer Info","Awaiting 3rd Party","Awaiting Internal","Awaiting Approval"}))

Formula of D6 (Not functioning)
=SUM(COUNTIFS(Requestor_Location,CentralS,Status,{"New","Work in Progress","Customer Replied","Awaiting Customer Info","Awaiting 3rd Party","Awaiting Internal","Awaiting Approval"}))
 
Last edited:
Upvote 0
Is "CentralS" found anywhere in the Requestor_Location column? If so, and if that is supposed to be one of the criteria, then it needs to be enclosed in quotes. Also, I see the formula uses a "_" between Requestor and Location, and the table heading (those are named table headings, right?)...does not.
 
Upvote 0
Sorry, Even with the " " the CentralS didn't work. CentralS is meant to be a range. I took the list from Central, duplicated it and removed the locations which I didn't want counted. The heading for Requestor Location does not contain the "_" while the formula does.
 
Upvote 0
I can't tell what specifically is being referred to by "Requestor_Location" and "Status". Did you assign a name to this data table and are those table headings...like this example, where the table is called Table1:
Book2
ABCDEF
1StatusRequestor LocationRegionCount2
2in progressCentralSCentral
3new resolvedthereCentral
4customer repliedCentralSCentral
5new resolvedthereNorthern
6NewCentralSCentral
7new resolvedthereCentral
Sheet1
Cell Formulas
RangeFormula
F1F1=SUM(COUNTIFS(Table1[Requestor Location],"CentralS",Table1[Status],{"New","Work in Progress","Customer Replied","Awaiting Customer Info","Awaiting 3rd Party","Awaiting Internal","Awaiting Approval"}))


I am assuming not...it sounds as if you've named ranges and for that part of your formula, you want to consider any rows where the Requestor_Location column includes an element in your CentralS range...is that correct? If so, I think you'll have to explicity list those elements in the CentralS range as criteria, rather than referring to the CentralS range as the criteria.
 
Upvote 0
You might try something like this:
MrExcel20200508.xlsx
ABCDEF
1StatusRequestor LocationRegion
2work in progressorg designCentralCount5
3neworg designCentral
4resolvedorg designNorthern
5newheadquartersNorthern
6newhr rockCentral
7resolvedhr rockCentral
8resolvedhr rockCentral
9customer repliedhr rockCentral
Sheet1
Cell Formulas
RangeFormula
F2F2=SUM(COUNTIFS(Table1[Requestor Location],{"org design","hr rock","headquarters"},Table1[Status],{"New";"Work in Progress";"Customer Replied";"Awaiting Customer Info";"Awaiting 3rd Party";"Awaiting Internal";"Awaiting Approval"}))

Where I've used table headings (e.g., Table1[Requestor Location]), you could use your named range instead, but the criteria to be found in that range (or under that column heading in my example) need to be explicitly listed.
Also note that one of the arrays uses elements separated by commas and the other uses semicolons. This is due to how COUNTIFS treats these arrays, considering one as a single column array and the other as a single row array.
 
Upvote 0

Forum statistics

Threads
1,214,403
Messages
6,119,308
Members
448,886
Latest member
GBCTeacher

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