Video extract as seen on YouTube, plus extended tutorial below.

Click the Full Screen button on the player to watch it in HD. |

In this tutorial we’re looking at the COUNTIF and COUNTIFS Formulas, and we'll take a look at a couple of different applications for them.

Plus download a practice workbook. *Note: This is an Excel .xlsx workbook. Please ensure your browser doesn't change the file extension on download.*

The COUNTIF/S functions work ALMOST in the same way as the SUMIF/S functions only they’re slightly simpler. So if you haven’t mastered SUMIF/S yet be sure to check out our SUMIF/S tutorial too.

COUNTIF extends the capabilities of the basic COUNT function by allowing you to tell Excel to only COUNT items that meet a certain criteria. New in Excel 2007 is the COUNTIFS function, which allows you to stipulate multiple criteria, hence the plural.

Enough explanation, let’s dive into an example as it’s easier to visualise.

## COUNTIF Function

The function wizard in Excel describes COUNTIF as:

=COUNTIF(range,criteria)

Looks fairly simple and it is. Let’s translate it into English now by applying it to an example. Say we wanted to count the number of times Dave appeared in column C of the table below.

Translated our formula would read like this:

=COUNTIF(count the number of cells in column C, that contain 'Dave')

We could even create a table under the data to count the occurrences of each builder:

Our formula in cell C12 would be:

=COUNTIF(C2:C7,"Dave")

While the above formula is good, if we were to copy it to the rest of the summary table (cells C11 to C14) we would have to manually change the cell references and builder’s name to get the correct answers.

To avoid this manual intervention, we can use absolute references, which will speed up the process of copying the formula to the remainder of column C.

With absolute references our formula would look like this:

=COUNTIF($C$2:$C$7,$B12)

The ‘$’ signs tell Excel that we don’t want the reference after the ‘$’ sign to change when we copy the formula. For example, if we copied the formula into cell C13 it would read:

=COUNTIF($C$2:$C$7,$B13)

In the above formula we can see that the only reference that changed was $B12, which became $B13.

The best way to understand how this works is to try it for yourself. Download the workbook used in this example here.

*Note: This is an Excel .xlsx workbook. Please ensure your browser doesn't change the file extension on download.*

Note: I used a basic example to illustrate how to use COUNTIF, but you could also achieve this count by builder using the subtotal tool in the Data tab.

## COUNTIFS Function

The function wizard in Excel describes COUNTIFS as:

=COUNTIFS(critera_range_1,criteria_1,criteria_range_2,criteria_2.....and so on if required)

Extending the previous COUNTIF example above, say we wanted to only summarise the data by builder for jobs in the South region. We could use the COUNTIFS function, as it allows us to set more than one condition.

Here’s how the formula would be interpreted if we wanted to count the occurrences of Brian in column C, where jobs were in the South region:

=COUNTIFS(count the number of cells in column C if, they contain ‘Brian’ and, if in column B, they arealsofor the South region)

Note: Excel will only include the cells in column C in the count when both conditions (Brian & South) are met.

Using absolute references, our COUNTIFS formula in Excel cell C20 would read:

=COUNTIFS($C$2:$C$7,$B20,$B$2:$B$7,$B$17)

**Try other operators**

Just like the IF Statement and SUMIF formula, the COUNTIF and COUNTIFS are based on logic. This means you can employ different tests other than the text matching (Brian & South) we’ve used above.

Other operators you could use are:

- = Equal to
- < Less Than
- > Greater Than
- <= Less than or equal to
- >= Greater than or equal to
- <> Less than or greater than

For example, if you wanted to count the jobs with an average > $300k the formula would be:

=COUNTIF($E$2:$E$7,">300")

Note: again I’ve used a simple example to illustrate this, but another way to achieve this summary table for each builder by region is to use a Pivot Table.

## Want to Learn More Excel Formulas

Why not visit our list of Excel formulas. You'll find a huge range all explained in plain English, plus PivotTables and other Excel tools and tricks. Enjoy 🙂

## Spread the Word

If you found this useful please share it with your friends and colleagues on Google+1, LinkedIn, Facebook and Twitter.

a lakshmi says

how to find missing numbers in 1 to 20000 please tell me excel formulas

Mynda Treacy says

Try this: http://www.myonlinetraininghub.com/find-missing-numbers-really-fast

Or this: http://www.myonlinetraininghub.com/finding-missing-numbers-in-a-range-using-vba

vlad says

what do i do if i want to count Daves sales value and not the number of time he appeared in the sheet

Mynda Treacy says

Hi Vlad,

I think you mean ‘sum’ or add up Dave’s sales value. In which case you can use a SUMIF formula for that.

Mynda

Catalin Bombea says

Hi Vlad,

What do you mean? A count is a count, no matter the column. Counting how many sales values we have for Daves will give the same number as counting how many times Daves is in that list. Maybe you want to add Daves’s values? Try SUMIF instead of COUNTIF. There is also a SUMIFS version.

Catalin

sheilagh romero says

What if I want to count everything in ONE column IF it = ‘pass’ OR IF it = FAIL ?

Example:Column J6:J100 can contain Pass, Fail or can be blank.

I want to count all the Pass and all the Fail

I tried:

COUNTIFS(J6:J100,”PASS”, “FAIL”)

But it comes up with a count = 0.

I have 4 = pass and 1 = fail so the count should be 5.

What did I do wrong?

thanks!

Catalin Bombea says

Hi,

COUNTIFS is used to apply different criteria to multiple columns, each criteria must be met in the same row for that row to be counted. COUUNTIFS works with an AND logic, it will not count a row if the criteria is “PASS” OR “FAIL” it will always consider “PASS” AND “FAIL”, and both those values cannot exist in the same time in the same cell.

You should use 2 COUNTIF:

=COUNTIF(J6:J100,”PASS”)+COUNTIF(J6:J100, “FAIL”)

Catalin

Barbara Gonzalez says

I need help in creating a formula to count only full shifts my hospitalist are working, and I don’t want the count to include Coverage shifts (phone or sick) how can I get Excel to total up only shifts (7p-7a) and not include BU (sick coverage) or CC (phone coverage) coverage in the totals?

Catalin Bombea says

Hi Barbara,

You have to upload a sample file on our forum. It will be very helpful if you prepare a sample data and some manual results, so we can understand exactly you situation.

Catalin

Raj Kumar Sharma says

excel formulas if column d is zero full amount of c, if d is 1, 50% of c, if d is 2, 1/3 of c and if d is 3 or more 0% of c

Catalin Bombea says

Hi Raj,

Try this one:

=C1*IFERROR(INDEX({1,0.5,0.333},MATCH(D1,{0,1,2},0)),0)

Omer says

Hi,

I am a basic excel user, I am handling an excel work book in 2016 version, I’ve got a query as follows:

I have 9 worksheets in an excel book and a specific column in each sheet which displays a series of reference numbers as:

GAD5-CDC-T2-349-230315-DWG-PP-STR-0114-0

GAD5-MGM-T2-349-230315-DWG-PP-STR-0114-0

GAD5-CDC-T2-349-230315-DWG-SD-STR-0114-0

GAD5-MGM-T2-363-250315-DWG-PP-STR-0119-0

GAD5-CDC-T2-363-250315-DWG-DD-STR-0119-0

GAD5-CDC-T2-363-250315-DWG-BD-STR-0119-0

GAD5-CDC-T2-259-51-050515-DWG-FD-S-0233-00

GAD5-CDC-T2-259-51-050515-DWG-TD-S-0233-00

GAD5-MGM-T2-259-51-050515-DWG-LD-S-0233-00

GAD5-MGM-T3-119-25-DDS-ST-1568-02

GAD5-MGM-T3-119-25-DDS-RT-1568-02

GAD5-MGM-T3-119-25-DDS-OT-1568-02

and so on, Please note: these numbers are not following any sequence. I want to count the number of times the second last series of number is appearing. In this Instance

0114 is 3 times

0119 is 3 times

0233 is 3 times &

1568 is 3 times

I want to count this by a formula and get the result in any other cell as a counter. I’ll appreciate if you could help me in this please.

Mynda Treacy says

Hi Omer,

You can use Text to columns to extract the second last series into another column. From there you can use PivotTables to count the instance of each number.

If you get stuck please post your question with a sample file on our Excel Forum so we can show you what we mean.

syediomer says

Hi Mynda,

Thank you for your kind response. I have posted my question to Excel Forum, with the sample file, your further help will be much appreciated. Many Thanks.

http://www.myonlinetraininghub.com/excel-forum/excel/text-to-columns-pivot-tables#p1317

Syed says

Hi I am a basic excel user, I am using excel 2016, my question is:

I am using the sumproduct formula to get my results the formula is

=SUMPRODUCT(SUBTOTAL(3,OFFSET(AR9:AR4148,ROW(AR9:AR4148)-MIN(ROW(AR9:AR4148)),,1))*(AR9:AR4148=”A”))

however in another column i want to use the same formula and I wan this to calculate the same way but the number not text, but it is not giving any result. For example I want the aforementioned formula to work like this

=SUMPRODUCT(SUBTOTAL(3,OFFSET(AR9:AR4148,ROW(AR9:AR4148)-MIN(ROW(AR9:R4148)),,1))*(AR9:AR4148=”1″))

But it is not giving the correct answer, can you please help me.

Catalin Bombea says

Hi Syed,

(AR9:AR4148=”1″) will assume that the column is formatted as text, it’s searching for text strings, not numbers (when a number is between double quotes, it’s a text, not a number). If you have numbers, and the column is formatted as numbers, simply use:

(AR9:AR4148=1) (without double quotes). Make sure you have the same data type in the formula and in that column. Or you can force that column to convert it to text, by adding a zero length string to that column:

(“”&AR9:AR4148=”1″) This way, both sides of the equation will have the same data type.

Syed says

Hi I am a basic excel user, I am using excel 2016, my question is:

I am using the formula =IF(X4030=””,TODAY()-W4030) to get the result but if the cell W4030 is blank the result is some strange value, I want excel to display nothing if the cell W4030 is blank, how can i fix this. Please help. Many Thanks

Mynda Treacy says

Hi Syed,

Just change your formula slightly:

Mynda

Syed says

Hi I am new Excel user, I have an excel sheet in which 2 columns are dates 1 is date item is received and the other one is the date when item was sent back with comments, I want to have a third column which tells how many days the item was sitting with us, I am doing it in a simple way =W225-U225 by this i get my desired result, my concern is, a cell in W column will be empty till item is not responded and if it is empty the cell with the formula is showing some strange numbers. how can I fix this.

Mynda Treacy says

Hi Syed,

You can use IF to check whether the second date field is empty. If it’s empty you can tell Excel to return blank, otherwise do the calculation. Here is an example formula:

A1 contains your received date and B1 contains the date the item was sent back.

Mynda

Syed says

many thanks Mynda!

Darshan Patil says

Very good information to learn exel

Joe says

Outstanding explanation, the “COUNTIFS” functions without any problems. However I need the formula to go one step further. I’m searching in two different columns (ranges) and have specified two different criterion, to this point no problems. The last and final step is to divide by a specified cell, if the cell has a “0” then I get the dreaded “#DIV/0”. Is there any way to get rid of the error “#DIV/0”?

=COUNTIFS($M$8:$M$27,$B$74)/$B$8

=COUNTIFS($M$8:$M$27,$B$74,$N$8:$N$27,$B$75)/$BP$7

In the above examples, both produce “#DIV/0” if the last cell (B8 and BP7) have a “0” in the cell. Understand I can’t divide by 0, is it possible to get rid of “#DIV/0?

Catalin Bombea says

Hi Joe,

You can Simply wrap your functions with the IFERROR function, then choose what you want to return in that case:

=IFERROR(COUNTIFS($M$8:$M$27,$B$74,$N$8:$N$27,$B$75)/$BP$7,”Error Message here, or a number”)

Cheers,

Catalin

Ruth says

Hi,

Can you help with a formula please. I need to use conditional formatting to highlight cells when a number is repeated more than 3 times, where in another cell is the word No.

I have managed the first part of the formula as =COUNTIF(A:A, A1,) > 3 but I can’t combine it with the 2nd condition. Below is an example of the data I’m using

Staff Number Deselected

95486245 Yes

36874592 No

48596314 No

95486245 No

36874592 Yes

48596314 No

95486245 No

95486245 No

36874592 Yes

36874592 Yes

So only the staff number 95486245 meets the criteria of appearing more than 3 times with ‘No’ in the deselected column.

Thanks

Ruth

Catalin Bombea says

Hi Ruth,

You can use COUNTIFS, you can set lots of conditions this way:

=COUNTIFS($A$2:$A$11,A2,$B$2:$B$11,”No”)

Catalin

John Collins says

GREAT EXPLANATIONS BUT THESE DON’T DO WHAT I WANT. I HAVE A 15X2 NUMERICAL TABLE IN WHICH FOR EACH VERTICALLY ADJACENT PAIR OF CELLS, I NEED TO COMPARE THE VALUE OF THE LOWER CELL WITH THAT OF THE UPPER CELL. IF LESS THAN THEN COLOUR LOWER CELL GREEN, IF EQUAL TO THEN YELLOW, IF MORE THAN THEN GREEN. (THE COLOURS COULD BE FONT COLOURS OR FILL COLOURS). ANY HELP YOU CAN GIVE ME WOULD BE VERY GRATEFULLY RECEIVED.

Catalin Bombea says

Hi John,a1 for the third color.

You have to take a look at this article: excel-conditional-formatting-with-formulas, you have to setup 3 conditional formatting rules, (one for each color), with very simple formulas: =a2=a1 for one color, =a2

Cheers,

Catalin

Alyssa Pease says

I’m currently using the following DATEDIF formula to run a day counter:

=DATEDIF(D2,TODAY(), “d”)

It works fine but I’d like to combine it with a COUNTEDIF formula so that the total will stop adding once another field is closed out, i.e. I have final date in another cell, and once that date is filled out I want the counter to stop. Does that make sense?

Catalin Bombea says

Hi Alyssa,

Hard to tell without seeing your data structure and a sample of a desired result.

Can you please upload a sample file to our Help Desk? (create a new ticket) It will be easier to provide a personalized answer.

Cheers,

Catalin

John R says

Very helpful in understanding the countif and countifs functions. Thank you. However I’m trying to use the countif function and want to increment the criteria by one for each cell that I paste the formula in. Example: A1 has 2 in it, A2 has 2 in it, A3 has 1 in it. B1 has this foumula =COUNTIF(A$1:A$3, 1) in it. B2 has this formula =COUNTIF(A$1:A$3, 2) in it. Etc.

Can you help me with this?

Catalin Bombea says

Hi John,

The easiest way is to use the ROW function, ROW(A1) will return the row number of the reference, use relative reference for the row number and it will increease when you copy down the formula:

=COUNTIF(A$1:A$3, ROW($A1))

If you want to copy the formula to the right, then use COLUMN function instead of ROW (column reference should be relative now):

=COUNTIF(A$1:A$3, COLUMN(A$1))

Catalin

Suresh N says

I am using three criterias to be matched and then out of them need a counts between date range. I have below formula which gives one count considering matched items for three criteria and another for counts between range. But I am looking for ciombined results from this.

=COUNT(IF(Sheet1!$H$2:$H$164=Sheet2′!S$2,IF(Sheet1!$G$2:$G$162=’Sheet2′!$Q3,IF(Sheet1!$B$2:$B$164=’Sheet2′!$P$2,sheet1′!$A$2:$A$173))))

=countifs(Sheet1!$K$2:$K$162,”>=01/01/2016″,Sheet1!$K$2:$K$162,”<=01/31/2016")

From the first formula we get few counts after that I want to filter them with between range.

how do I can combine this formula

Hope I will get results for it

Catalin Bombea says

Hi Suresh,

You can combine multiple criterias for a count using SUMPRODUCT:

=SUMPRODUCT((Sheet1!$H$2:$H$164=Sheet2!S$2)*(Sheet1!$G$2:$G$162=Sheet2!$Q3)*(Sheet1!$B$2:$B$164=Sheet2!$P$2)*(Sheet1!$K$2:$K$162>=”01/01/2016″)*(Sheet1!$K$2:$K$162<="01/31/2016")) Catalin

Archie says

Hi!

How about if I will count the Units of the Builder in the same date or month?

Thank you,

Archie

Catalin Bombea says

Hi Archie,

You can try this:

=COUNTIFS(A2:A7,”>=01/03/2008″,A2:A7,”<01/04/2008",C2:C7,"Dave")

This will count only entries for Dave, in March.

Catalin

Dayan Montano says

Hi,

How can I modify the Countifs function to count the number of populated cells regardless of the value in criteria range1? I have multiple Customers and I just want to count them if criteria range2 contains a “D1″ code.

=Countifs($C$2:$C$7,???,$B$2:$B$7,”D1”)

Thanks

Catalin Bombea says

Hi Dayan,

If you want a single criteria, use COUNTIF instead of COUNTIFS:

=Countif($B$2:$B$7,”D1″)

Catalin

Dayan Montano says

Thank you Catalin! I was probably not clear.

If there is a customer name present in range1, I need to count it regardless of who the customer is, but only if range2 has the code D1. I found the following code for non-blank cells [“”&””].

=COUNTIFS(Summary!U:U,””&””,Summary!Q:Q,”D1″)

However my range1 is populated via a VLOOKUP and I think it’s counting even if the cell is blank. I am using the IFERROR(VLOOKUP(lookup_value,table_array,col_index_num,[range_lookup]),””) function to populate it. Any tips on how to fix it?

Regards,

Catalin Bombea says

You Should try this:

=SUMPRODUCT((Summary!U:U<>“”)*(Summary!Q:Q=”D1″))

It’s more reliable than COUNTIF.

Cheers,

Catalin

Archie says

Hi!

In your formula it shown only how many names for Brian’s and name of Brian in the South. Please I want to know the formula to calculate the Units of Mr. Brian which I manually count is 13.

Thanks

Catalin Bombea says

Hi Archie,

Try: =SUMIF(C2:C7,C3,D2:D7) where C2:C7 is the criteria range, C3 has the criteria, and D2:D7 is the range to sum. Keep in mind that the criteria range and the range to sum must have the same number of rows.

Cheers,

Catalin

Shankar says

this formula pulling up a wrong data.. Do you have any work around to resolve this.

Mynda Treacy says

Hi Shankar,

Not without seeing your data and formula. If you want to raise a Help Desk ticket and upload your workbook we can take a look.

Mynda

Joshua says

This has really helped me. And i think im getting the hang of it but a little stuck.

Using your “keeping it simple” outline above can you help me with this?

=COUNTIFS(count the VALUE of cells in column D if, in Column C they contain ‘Larry’ and, if in column A, they are also for the month of MAY)

Using your image above, lets pretend for a moment Larry sold 10 units on May 5th and 8 units on May 22, the Answer in this statement would be 18

Thoughts?

I tried this

=COUNTIFS(Sheet1!K:K,”6/30/2015″,Sheet1!B:B,”Larry”)+COUNTIFS(Sheet1!E:E,”=>1″)

But that just counts all 6/30/2015 and all larrys.

Mynda Treacy says

Hi Joshua,

If you want to add up the units then you need a SUMIFS formula like this:

SUMIFS is explained here and SUMIFS referencing dates is explained here.

I hope that helps.

Kind regards,

Mynda

Kate Alderley says

I’ve used the steps above to try and set up a simple overview sheet but I get an error:

A value used in the formula is of the wrong data type

The formula is:

=COUNTIFS(Sept!D3:D500,”1st”, Sept!I3:L500,”Offer Accepted”)

The data in the cells I’m looking at are all formatted as ‘general’

Catalin Bombea says

Hi Kate,

The COUNTIFS function expects that

each additional rangemust have the same number of rows and columns as the criteria_range1 argument (The ranges do not have to be adjacent to each other). The problem is that in your formula, criteria_range1 has 1 column D3:D500, but the second criteria_range2 has 4 columns: I3:L500. You have to add new criterias for each column: =COUNTIFS(Sept!D3:D500,”1st”, Sept!I3:I500,”Offer Accepted”, Sept!J3:J500,”Offer Accepted”, Sept!K3:K500,”Offer Accepted”, Sept!L3:L500,”Offer Accepted”)Note that only if each cell in I:L columns contains the criteria: ”Offer Accepted” will be counted. For example, if D3 contains “1st”, the row will be counted only if I3, J3, K3 and L3 contains ”Offer Accepted”.

If you want a count if D3 contains “1st” and at least one of the I3, J3, K3, L3 cells has the second criteria, you need another approach, the countifs formula will not work.

Cheers,

Catalin

Cheers,

Catalin

Beric Boxall says

I am trying to add exceptions to my formula =COUNTIF(G9:G45,”Yes”)/COUNTIF(G9:G45,””) but as the first exception is to ignore blank cells the second needs to be COUNTIF(G9:G45,”N/a”)

This formula does not allow me to include the second exception.

Beric Boxall says

That should be =COUNTIF(G9:G45,”Yes”)/COUNTIF(G9:G45,””) and the next statement to add is COUNTIF(G9:G45,”N/a”)

Mynda Treacy says

Hi Beric,

I’m not following you, sorry. Is COUNTIFS what you’re after? If not please send us an example file via the help desk so we can see your question in context and an example of the desired result.

Thanks,

Mynda

Beric Boxall says

Unsure why it would not allow me to add the full formula, I was trying to include the for exceptions however I have now resolved this simply by taking the blanks away and no longer needing to account for them. Sometimes the obvious answer is just too obvious.

Mynda Treacy says

Hi Beric,

It’s probably the HTML formatting interpreting the formula characters as HTML.

Glad you figured it out. Next time try wrapping your formula in Pre tags e.g. <pre>=IF(etc….)</pre>

Mynda

Deronda says

My problem is simple but I cant seem to get it right.

I have a column of Names and a column with Y or N

i’m simply trying to create a formula that gives me the % of Y for that particular name

=(COUNTIFs(C2:C16,”L.Woods”, (X2:X16,”Y”)

I’m getting an error ..what am I doing wrong?

Signed,

Beginner Excel user

Mynda Treacy says

Hi Deronda,

You need 2 COUNTIF formulas; the first counts the Y’s for that name and the second counts all the Y’s. You then divide one by the other to get the % of Y’s for that name:

Your formula references a range X2:X16. I’m not sure what is in this column or why it’s in your formula. If my formula above doesn’t work then please send us a sample file via the Help Desk so we can see your question in context.

Thanks,

Mynda

Sanjiv Patel says

I am counting for instances where status is either Approved OR Implemented, AND Date Received by CAFGB is less than or equal to end of the month of a date in header in row 48 (which is 1st of that month) AND Validation Start Date is either NULL OR in the following month. I am using curly braces for OR condition – along with SUM.

Following works, but it is too long:

=SUM(COUNTIFS(Data[[#Data],[CAFGB Status]:[CAFGB Status]],{“Approved”,”Implemented”}, Data[[#Data],[Date Received by CAFGB]:[Date Received by CAFGB]],”<=" & EOMONTH(AG$48,0), Data[[#Data],[Validation Start Date]:[Validation Start Date]], "")) + SUM(COUNTIFS(Data[[#Data],[CAFGB Status]:[CAFGB Status]],{"Approved","Implemented"}, Data[[#Data],[Date Received by CAFGB]:[Date Received by CAFGB]],"” & EOMONTH(AG$48,0)))

I was thinking that it should work with following shortened expression, but it doesn’t:

=SUM(COUNTIFS(Data[[#Data],[CAFGB Status]:[CAFGB Status]],{“Approved”,”Implemented”}, Data[[#Data],[Date Received by CAFGB]:[Date Received by CAFGB]],”” & EOMONTH(AG$48,0)}))

What am I doing wrong in the shorter version? What can I do to make it work?

Catalin Bombea says

Hi,

Can you please upload a sample workbook with your data structure used in this formula? It will be a lot easier to understand the situation and test the solution.

Until then, you can try a general solution:

`=SUMPRODUCT(($A$1:$A$10={"Approved","Any"})*($B$1:$B$10< =EOMONTH(TODAY(),0))*C1:C10)`

Use our Help Desk system.

Cheers,

Catalin

Rachana says

Hi Mynda,

I using a formula =COUNTIFS(‘6-26-52 Weeks’!G4:G52,”=Mike”,’6-26-52 Weeks’!J4:J52,”=April”,’6-26-52 Weeks’!Q4:Q52,”=Y”‘6-26-52 Weeks’!R4:R52,”=True”)

It doesnt count “Y” from Col Q of all “Mike” in col G with conditions that J should have “April” and Col R should be “True”. It doesnt even throw an error in excel either.

please can you advise.

Regards,

Rach

Catalin Bombea says

Hi Rachana,

Please upload a sample file so we can analyze it. Use our Help Desk to send us the file.

Cheers,

Catalin

Rachana says

Hi Catalin,

I am using below formula to count all Ys of Mike in another sheet with conditions to check if Months column showing “April” and T/F column showing True. Please can you advise.

=COUNTIFS(’6-26-52 Weeks’!G4:G52,”=Mike”,’6-26-52 Weeks’!J4:J52,”=April”,’6-26-52 Weeks’!Q4:Q52,”=Y”’6-26-52 Weeks’!R4:R52,”=True”)

01/04/2014 31/03/2015

Name Target date Completion date Target Met Months T/F

Mike 01/01/2014 20/12/2014 Y January True

Mike 01/02/2014 02/02/2014 N February False

Jenny 01/03/2014 25/02/2014 Y March False

Jenny 31/03/2014 01/04/2014 N March True

Regards,

Rach

Catalin Bombea says

Hi Rachana,

The Months column is in fact a date value, formatted as “mmmm” to show only the month name. You cannot compare a value to a text string.

Use

`=SUMPRODUCT((A3:A6="Mike")*(D3:D6="Y")*(F3:F6="True")*(MONTH(E3:E6)=1))`

to convert dates to months numbers.

Catalin

janine says

I have a spreadsheet where Column B contains the numbers either 1, 2, or 3. I want to count the rows that contain a “1” in Column B if there is a corresponding “x” in Column C or D or E and I only want to count it once (because it could contain an x in C and/or D and/or E). Can someone help me?

Mynda Treacy says

Hi Janine,

You can use this formula:

Entered with CTRL+SHIFT+ENTER as it’s an array formula.

Kind regards,

Mynda

janine says

Thanks for the help– but when I input the formula I get the error “a value used in the formula is of the wrong data type”

janine

Mynda Treacy says

Hi Janine,

Perhaps your ‘numbers’ in column B are actually text. You can tell by trying to SUM them. If you get an error then they’re text. You’ll need to convert them to numbers.

If that doesn’t work then I’ll need to see your workbook which you can send me via the Help Desk.

Kind regards,

Mynda

ravikumar says

wow its super

Mynda Treacy says

Cheers, Ravikumar 🙂

Robert says

Hi,

I want to use countifs with a date range but subtract 7 days from the date range use to select my occurrencies.

Thank you for your time 🙂

Catalin Bombea says

Hi Robert,

Can you upload a sample of your data, it will be useful for us to understand your situation. You can use our Help Desk: http://www.myonlinetraininghub.com/help-desk

Catalin

Eric says

I’m so glad you still check this for comments, I have a weird issue.

I’m using =COUNTIFS($O$1:$O$130,”=1*”,$R$1:$R$130,”Yes”) and it’s being picky about the O1:O130 range.

If the value in O includes a letter e.g. 1711A it will get counted, however if the value in O does not contain a letter e.g. 1711 it does not get counted! What am I missing?

Catalin Bombea says

Hi Eric,

1711A is interpreted by excel as a text string. 1711 is seen as a number, with numbers you have to deal in a different way.

Try:

=SUMPRODUCT((LEFT($O$1:$O$130,1)=”1″)*($R$1:$R$130=”Yes”))

It will work on both text and numbers.

Catalin

Kyle says

Hi,

My cells contain one of the four things listed below

1) random dates

2) the letter N

3) the letter I

4) N/A

I’m trying to write a formula that will give me a percentage of the cells that contain dates out of the total number of cells that I have selected. I would also like to exclude from the percentage listed above all cells containing N/A. How would l do that?

Catalin Bombea says

Hi Kyle,

Assuming that your range is in column A, starting from row 1, use this formula in cell B1:

=CELL(“format”,A1) and copy it down as needed.

The formula:

will give you the percentage needed.

Catalin

Kyle says

The criteria listed above is all listed in the same column. So the individual cell in the column has one of the four criteria listed above. Here is a copy of one of the columns:

Course title

N/A

N/A

N/A

N/A

N

N

9-Dec-13

N/A

N/A

N/A

N/A

N

N/A

N/A

N

N/A

N/A

N

N

N/A

N/A

N/A

N

N

N/A

N/A

N

N/A

N/A

N/A

N

N

N/A

N/A

N/A

N

N/A

N/A

N/A

N

N

N/A

N/A

N/A

Catalin Bombea says

Hi Kyle,

Please try the formulas already provided. If the problem is not solved, use our Help Desk System: http://www.myonlinetraininghub.com/help-desk to create a sample file and to provide more details on this problem.

Thank you,

Catalin

Nataly says

Hello I’m doing the countif formulas correctly.

I could swear to you but it’s telling me that the correct answer is 0.

And I know it’s not, because there are certain products, there’s a few but it keeps telling me it’s 0.

I have no clue why, but do you think you can help me with this? Please.

Mynda Treacy says

Hi Nataly,

Sure we can help you. Please send your file with the offending formula to us via the Help Desk.

Thanks,

Mynda.

Sanjiv Hede says

Very Useful ones

Thanx & Kind Regards

Mynda Treacy says

You’re welcome, Sanjiv 🙂

Jo Case says

Hi there

I find your tutorials really helpful. However I’m stuck on a problem that I can’t seem to find a solution to. In the first example above consider you want to know the number of times Doug sold 8 units in the month of January. I have a similar table where I want to know how many decisions a staff member has made in a certain month. The month is found in the same date structure as in your table. As soon as I’m adding the MONTH function in, I’m struggling to find the solution. I’ve tried arrays, and the straight COUNTIFS. Any suggestions? Cheers, Jo

Mynda Treacy says

Hi Jo,

You need to give your COUNTIFS a date range that incorporates the month you’re counting. Here is a tutorial on SUMIFS using dates as critiera. The logic for the date range is the same for COUNITFS.

Let me know if you get stuck.

Kind regards,

Mynda.

BAM says

Hello

I am working in a table with 9 columns and 50 rows. All cells in the table have COUNTIFS formulas based on the column identifier. I get accurate results from cells in all columns but the last 2 (8 and 9) and I’m not sure why. I feel that the formulas are designed correctly but only “0” is returned in all cells in the last two columns.

Is something wrong with the formula? Is there a limit on COUNTIFS forumlas that can be applied in a worksheet? Have you seen/heard of this before?

Column 1= COUNTIFS(Input!$P$4:P30,”=”&$C$6,Input!$G$4:G30,”=”&B9)

Column 4=COUNTIFS(Input!$P$4:P30,”=”&$F$6,Input!$G$4:G30,”=”&B9,Input!$AC$4:AC30,”=”&”Major Issue”)

Column 6= COUNTIFS(Input!$G$4:G30,”=”&B9,Input!$AC$4:AC30,”=Not Applicable-Issue has insignificant impact”)

Column 8= COUNTIFS(Input!$G$4:G30,”=”&B9,Input!$AC$4:AC30,”=Not Applicable — Issue has no impact”)

Column 9 = =COUNTIFS(Input!$G$4:G30,”=”&B9,Input!$AC$4:AC30,”=Not Applicable — Other”)

Mynda Treacy says

Hello again Tina,

Looking at your formulas I would expect Columns 6, 8 and 9 to return zero. The last criteria in each formula is stated with an = inside the double quotes. Now it’s possible this is correct but I suspect not and this is why:

Your formula in column 6 says count the values in G4:G30 that = what ever is in cell B9

ANDwhere the values in AC4:AC30 contain the text =Not Applicable-Issue has insignificant impacti.e. the equals sign is in front of the text Not Applicable-Issue has insignificant impact like this:

=Not Applicable-Issue has insignificant impact

I suspect the formula should be more like this:

If that’s not the problem, send me the workbook via the help desk and I’ll take a look.

Kind regards,

Mynda.

Tina says

Hello-

I have a table with 9 columns and 50 rows. All cells have countifs formulas that accurately represent the reference data with the exception of the last 2 columnns. The last 2 columns are not pulling in any data even though the countifs formulas are sturectured exactly the same.

Is there a column limit per worksheet? Am I doing something wrong?

Mynda Treacy says

Hi Tina,

Perhaps you can send me the workbook via the help desk so I can see the data you’re working with.

Kind regards,

Mynda.

Haitham says

HI

is it possible to use a function for count all the cells in a column except the cells those are “empty and have a dates”

Thanks

MikeBanawa says

Hello Haitham,

Yes it is possible. You can use a combination of count formulas for your conditions.

But first of all, does your data contain only letters or does it have numbers as well?

I’ll assume your data contains only: Empty cells, Dates and Words/letters/Alphanumeric

Let’s say that all of your data are in Column A1 to A10:

Since dates are numbers and COUNTA will not count empty cells you can combine both formulas by using a simple subtraction:

This formula will return the number of cells that only contains letters.

you can also experiment on the formula =COUNTBLANK which literally counts blank cells in a range.

If you want a bit more detailed explanation on the mentioned formulas, we have a blog post about Excel COUNT, COUNTA and COUNTBLANK Functions. Just follow this link: http://www.myonlinetraininghub.com/excel-count-counta-and-countblank-functions

Hope this Helps. Thanks!

Mike

Haitham says

Thankd for your efforts!

Jenny says

Very helpful page – Thank you! However, I do have a question…

In cell [B12] I have the formula: =COUNTIF(B2:B8, A10)

so count, if cells within the range B2-B8 (then C2-C8 etc) contain the value in A10, (then A11, then A12).

I want to copy this formula across and down, so:

[B13]=COUNTIF(B2:B8, A13) then [C13]=COUNTIF(C2:C8, A13) etc…

[B14]=COUNTIF(B2:B8, A14) then [C14]=COUNTIF(C2:C8, A14) etc…

[B15]=COUNTIF(B2:B8, A15) then [C15]=COUNTIF(C2:C8, A15) etc…

However, when I copy across, the vertical range is correct but the reference cell also increments by one column:

[C13]=COUNTIF(C2:C8, B13) then [C13]=COUNTIF(D2:D8, C13) etc

How do I rectify this? It will be so long winded to type these in manually as I have a few to reference.

Jenny says

OMG Sorry – I think I misunderstood the $ thing – I tried it and it works. Fiddly but I am not sure Excel will copy correctly in both directions. I may just have to use =COUNTIF(B2:B8,$A$10) and =COUNTIF(B2:B8,$A$11) etc for all rows before copying across… Sorry to have bothered you!

Mynda Treacy says

No problem, Jenny. Glad you figured it out yourself 🙂

Surender says

if there is multiples states and in adjacent is cities name how can i count in excel that one state have how many cities

Mynda Treacy says

Hi Surender,

Just count the number of instances of states.

Assuming the cities aren’t repeated/duplicated anywhere.

Kind regards,

Mynda.

Paul says

This was really well-explained. Thanks very much for your effort!

Carlo Estopia says

Hi Paul,

Thanks, on behalf of Mynda.

Cheers,

CarloE

Cary says

Hello Mynda,

Is it possible to use COUNTIFS in this fashion:

COUNTIFS(b1:b20,criteria,n1:y20,criteria)

I am getting a #value! error and believe that it must be because of the n1:y20 range. Am I only able to compare single columns?

Thank you in advance for your time,

Cary

Carlo Estopia says

Hi Cary,

Precisely. You might want to separate the ranges like COUNTIFS(b1:b20,criteria, n1:n20, criteria, y1:y20, criteria)

Cheers,

CarloE

Cary says

Thanks Carlo, I appreciate your time!

Rajesh says

Many Many Thanks. This is the greatest way to learn.

Best Regards,

Mynda Treacy says

Cheers, Rajesh 🙂

Gaurav Sahai Saxena says

Can you help me in understanding following formula

=COUNTIFS(‘Tickets Tracking 2013’!$G$7:$G$71, 3, ‘Tickets Tracking 2013’!$H$7:$H$71, 2013) + COUNTIFS(‘Tickets Tracking’!$G$7:$G$73, 3, ‘Tickets Tracking’!$H$7:$H$73, 2013)

Carlo Estopia says

Hi Gaurav,

First, it has a sheet called Tickets Tracking 2013

Second, In this sheet, you are counting if

Ranges G7 to G71 has or equal to 3

and

Ranges H7 to H71 has or equal to 2013

First Formula:COUNTIFS(‘Tickets Tracking 2013′!$G$7:$G$71, 3, ‘Tickets Tracking 2013′!$H$7:$H$71, 2013)

Third, You are adding –see the plus (+) sign — the result in the second step (first formula) to the fourth step(second formula):

Fourth, You are counting if

Ranges G7 to G73 has or equal to 3

and

Ranges H7 to H73 has or equal to 2013

Second Formula: COUNTIFS(‘Tickets Tracking’!$G$7:$G$73, 3, ‘Tickets Tracking’!$H$7:$H$73, 2013)

Cheers,

CarloE

Lelbron says

Thanks! I needed this for work and your guide was what got me through it!!

Mynda Treacy says

Cheers, Lelbron. Glad I could help 🙂

Pam says

Hi Mynda,

You make everything sound so easy!!! So I have a spreadsheet that has dates from 7/1/12 – 2/28/13 and I am trying to count how many entries were made for each month but there were several entries that were made on each day, e.g. 5 on 7/2/12, 9 on 7/19/12, etc. but when I use the COUNTIFS formula of COUNTIFS(B2:B1400, “>=7/1/2012”,B2:B1400,”<=7/31/12") it seems to only be counting the dates once. How can I get it to count each entry instead of each date? THANK YOU in advance.

Carlo Estopia says

Hi Pam,

Try to check your cell format. It might not be dates.

You may send it also through HELP DESK so we can have a good look at it.

Cheers.

CarloE

Haitham says

Someone support me please,

Can I use CountIFs formula with three column, one of these column has two criteria first criteria “On Air” and the second “RFT”

it will appreciated if you know the answer

Regards

Carlo Estopia says

Hi Haitham,

Formula:

result: 8

rows 2 and 3 do not qualify.

Please use the data below:

Cheers.

CarloE

Haitham says

Many thanks CarloE

What about the below issue, i used countifs but not work with two text creteia in the same column:

North Done On Air

South Waiting On Air

South Done CW

North Done RFT

North Waiting On Air

South Waiting RFT

North Done On Air

South Done RFT

North Done CW

South Done RFT

=COUNTIFS(A1:A10,”North”,B1:B10,”Done”,C1:C10,”On Air”&”RFT”)

Regards

Mynda Treacy says

Hi Haitham,

You can use SUMPRODUCT for counting with OR criteria:

Kind regards,

Mynda.

Haitham says

Thank you Mynda and God bless you

Mynda Treacy says

You’re welcome, Haitham 🙂

Haitham says

Hi Mynda,

i hope u well

kindly I used above formal which was very usful for me but when i replace the “=” by “” then it isnt work properly

can you help please in case i need to use except “” as below formla but it gave me result 12 while it must be 7 :

=SUMPRODUCT(($B$11:$B$194=”Darin”)*(($AC$11:$AC$194″”)+($AC$11:$AC$194″Waiting”)))

Thanks

Mynda Treacy says

Hi Haitham,

You have some double quotes after $AC$194 in your formula above. They need to be removed.

If that doesn’t fix it then you can send me the Excel file and I’ll take a look.

Kind regards,

Mynda.

HAMAD ONSO says

bring me questions and answers in excel

Carlo Estopia says

Hi Hamad,

Please send us your concerns through our HELP DESK.

Cheers.

CarloE

Ross says

Hi Mynda,

Really appreciate your clear instructions on the use of the excel formulas – thanks!

However, when I apply the COUNTIFS formula to the following data I just receive a “0” all the time. Here’s the example data and the formula I’ve written (I’m trying to determine how many entries for each Location there are for each Process):

Column B – Process (multiple entries of each of the following)

Search

Service

Access

Column E – Location (multiple entries of each of the following)

T1

T2

Formula:- =COUNTIFS(E2:E1300,T1,B2:B1300,Service)

As I mentioned, the formula continues to just provide “0”.

Appreciate any help you can provide.

Many thanks,

Ross

Carlo Estopia says

Hi Ross,

First,

Your formula’s criteria don’t have the double quotes(“) and equal(=) signs:

=COUNTIFS(E2:E1300,”=T1″,B2:B1300,”=Service”)

Second,

It also looks as if you’re trying to provide two criteria for counting; that is,

you likely want to satisfy that Location must be T1 and Process is Service.

And looking at your Example, none would satisfy that. That is, If I understood it

correctly that you’re trying to use this mock data of yours and there no entries after E3 and B4, respectively.

I could see though that your formula reaches 1300.

Please do clarify what are the criteria that you’re really trying to have here.

Send your file to Help Desk for a complete picture of your scenario. Thus we can

have a better look at it.

Sincerely,

CarloE

Subash says

Dear Mynda,

First of all thank you for such a wonderful site which helps us so very tremendously.

I have a workbook with several worksheets in it. In the worksheets in different columns I have a reference number. The reference number should not be more than 2 times. Say, once debit and once credit. It is never repeated on the same sheet. I want to use COUNTIFS formula but it always gives me 0, but if I use it only on one sheet it gives me 1, which is correct.

For example in sheet “SUBASH” column “J:J” has the reference numbers and in sheet “MYNDA” column “J:J” has the reference numbers. In Sheet “MYNDA” in cell k2 if I put this formula COUNTIFS(J:J,J2) I get 1 which is correct, as the reference in J2 appears only once in this sheet in the column J:J. When I change the formula to COUNTIFS(J:J,J2,’SUBASH’!J:J,J2) I get the answer 0, where as it should be 2 as the value in J2 in MYNDA also appears in the column J:J in the sheet SUBASH (not necessarily in J2 in sheet SUBASH).

If I get the correct answer, I should be able to drag the formula down so that I get the same result from J3, J4 and so on.

Above I have mentioned only two sheets, but in my workbook I have many more.

Kindly advise how should I go about getting the correct result.

Thanks and best regards,

Subash

Subash says

Dear Mynda,

I worked my way out by using the SUMPRODUCT((J:J=J2)+(’SUBASH’!J:J=’MYNDA’!J2)) this formula gives me the correct answer 2. But since I have many sheets, have to write the formula for 20 times in each sheet, would appreciate if there is a shorter formula to capture the data from all the sheets.

Thanks and best regards,

Subash

Carlo Estopia says

Hi Subash,

I would suggest that you send your file through Help Desk so I could fully understand what’s going on.

It’s good that you have worked around the problem; however, I need to see the data and the formula and the logic of it so I can help you with it.

Sincerely,

Carlo Estopia

Carlo Estopia says

Hi Subash,

I have replied with your recent message.

Anyway, please consolidate all your concerns and send me your file through Help Desk with the mock data and the results or formulas you want to achieve.

Sincerely,

CarloE

Jhosel says

I’m find it hard to combined countifs with left formula. Below is my scenario:

Total Age (column A)

37

35

35

35

28

28

Queue (Column B)

2S0096

1S0096

1S0096

1S0096

1S0096

1S0096

Column I need to count all 30 above from column A that is starting with 1S because I need to count all Aged items from 2S separately.

i tried the formula below but it’s not working:

=COUNTIFS(A3:A10,”>=30″,B2:B5,LEFT(B2:B5,2))

Hope you can help me with this. 🙂

Carlo Estopia says

Hi Jhosel,

Your formula is good except for the LEFT FUNCTION part. I hope you’ll agree if we would avoid that complication and instead use a wildcard search.

here it is:

=COUNTIFS(A2:A7,”>=30″,B2:B7,”=2S*”)

result : 1

=COUNTIFS(A2:A7,”>=30″,B2:B7,”=1S*”)

result : 3

For more on COUNTIFS

Sincerely,

CarloE

Jhosel says

Thanks much with this Carlo! i never knew it could be this simple. ;p This will help me a lot with all the reports that I’m doing. thanks again and keep it up! 🙂

Carlo Estopia says

Hi Jhosel,

In behalf of Mynda and Philip, I say you’re welcome.

It’s our pleasure to make our visitors satisfied as much as possible.

Sincerely,

CarloE

Kay says

Hi Mynda,

I hope you can help me, I’ve spent hours on this already!!! I need to count the total number of job titles contained in a spreadsheet that do not equal Manufacturing, Agency Manufacturing or Agency Indirect.

Any advice you can give me will be very gratefully received.

Best regards, Kay

Mynda Treacy says

Hi Kay,

Assuming your job titles are in cells A1:A5 you can use this formula:

Kind regards,

Mynda.

ABRAHAM says

EXAMPLE

A1 B1

ABB 15451

EBB 15454

ABB 159685

EBB 8754

ACC 8759654

ABB 54875

I need to have the total of abb ie 230011 in one cell.

please advise the formula

Mynda Treacy says

Hi Abraham,

You can use this formula:

Kind regards,

Mynda.

ABRAHAM says

YOU SAVED MY LIFE!!! THANKS A LOT

ABRAHAM says

hi thanks for the formulas. i need one more formula: if a certain colum contains different names and the colum next with numbers and i want the total sum of those numbers according to the names then what is the formula? please advise

Nitin G says

The explanation part is really Good.

Thanks for sharing the knowledge.

Mynda Treacy says

🙂 You’re welcome, Nitin.

Karen says

Tried a COUNTIFS formula and it is not returning a number just a value error.

=COUNTIFS($AC$10:$AC$2832,”EAP”,$B$10:$B$2831,B2839)

Will the formula work if some of the cells in column AC are blank?

Mynda Treacy says

Hi Karen,

I your second range B10:B2831 is a different size to the first range AC10:AC2832. You need to make them both the same size.

Kind regards,

Mynda.

Trish says

Hi, wow…thank you for your time here on your website. You explain things perfectly! I recently decided I wanted to learn what excel is all about instead of feaing it and saying “no I don’t like excel”. I am trying to learn how to track expiring certificates at work. Exp: DL from John Doe expires 10/25/2016; next cell would read how many days left until expiration. I also saw how it could be have a color with it. It could turn yellow within 30 days of expiration and red once the day has come and passed.

Again thank you for your time, I hope you can point me in the right direction :)!

Mynda Treacy says

Hi Trish,

Thank you for your kind words 🙂

You can use the DATEDIF function to calculate the number of days between two dates (your expiry date and today’s date).

You can then use Conditional Formatting to detect if the date is <= 30 days and colour the cell yellow. I hope that helps. Kind regards, Mynda.

Elijah says

how can i count a column but stop counting if data goes to another column on excel

Mynda Treacy says

Hi Elijah,

If your data goes into another column then it won’t be in the range of the first column and therefore won’t be counted. I must be missing something? Perhaps you can send me an example.

Kind regards,

Mynda.

RKM says

Hi Mynda ,

I just want display the count of two strings belonging to same column

For Ex: Two strings are “Blue” and “Green” I want formula for excel 2007 which counts sum of recurrence of these two strings

Please help me out.

King Regards,

RKM

Mynda Treacy says

Hi RKM,

Can you please tell me how your data is laid out, or even better, send me an example by logging a ticket on the help desk.

Kind regards,

Mynda.

RKM says

Dear Mynda,

Sure,

As I am not able to raise ticket, I will explain you my problem here only,

See, my data is arranged in following way:

Cell Location Strings

A1 Ram

A2 John

A3 John

A4 Ram

A5 Jack

A6 Ram

I just want formula which give me total count of Ram and John.

Means I want to know What is the sum of John and Ram.

Here we can simply count it as Ram+John=5

I require formula which display count=5

Mynda Treacy says

Hi RKM,

=SUMPRODUCT((B1:B6=”John”)+(B1:B6=”Ram”))

More on SUMPRODUCT here.

Kind regards,

Mynda.

RKM says

Thanks! Mynda.

saeed says

hi

plz can you help me .

i want a formula to write text or number in column A ( example ) and a number in column B then it will paste the text in next column ( 2 or 4 ) according to number i write .

for example :

in column A ( welcome ) and in column B ( 3) so i want ( welcome ) to appear in column C,D & E ( ONCE ONLY) .

AND IF I write 4 then in C,D,E & F .

Mynda Treacy says

Hi Saeed,

That’s a good question. Here’s a formula you can use in cell C1 then copy across to D, E and F:

Kind regards,

Mynda.

Cate says

Wow! Wonderfullly explained.

Mynda Treacy says

Thanks, Cate. Glad we could help 🙂

Abby says

SO HELPFUL! Thank you so much for posting this.

Mynda Treacy says

Cheers, Abby 🙂

Dee says

goodmorning, thanks for the reponse. it is still not working.

The formula needs to meet both criteria 1) wrong status AND 2) CPSUB OR B7SUB OR E9SUB.

It is saying to try DCOUNTA when you click on the function .

I really appreciate your help.

Have agreat day,

Dee

Mynda Treacy says

Oh, sorry.

Try:

=SUM(COUNTIFS(‘RAZ00302′!R:R,”WRONG STATUS”,’RAZ00302’!T:T,{“CPSUB”,”B7SUB”,”E9SUB”}))

Enter formula with CTRL+SHIFT+Enter as it is an array. You should be able to see curly brackets at either end of the formula when viewed from the formula bar. Like this:

{=SUM(COUNTIFS(‘RAZ00302′!R:R,”WRONG STATUS”,’RAZ00302’!T:T,{“CPSUB”,”B7SUB”,”E9SUB”}))}

Note: when you copy and paste the formula from the web page you may need to type in the double quotes and apostrophes, as sometimes they are italicised on the web and this won’t work in Excel.

If that doesn’t work I must be missing something so please send me your file by completing a Help Desk ticket on the contact us page.

BTW; I’m not sure what you mean by “It is saying to try DCOUNTA when you click on the function”. But hopefully the above formula will work now.

Kind regards,

Mynda.

Dee says

hey Mynda,

This is work related so sending the document would probablly be a bad idea. I am sorry. It now works better but is ignoring the last 2 criteria :B7SUB E9SUB. I am so grateful for all your help. You sure do know a bunch about formulas.

have a good night

Dee

Mynda Treacy says

I understand. Usually what people do is send me an edited version of their Excel file thus removing any sensitive information. It’s always an option if you get stuck.

Dee says

hi. was unable to get it to work and could not get file to upload.

It counts the first item in the array but not the last 2. B7SUB E9SUB .

I guess I’ll just keep trying. appreciate your trying tohelp.

Dee

Mynda Treacy says

How big is your file? You could email it to me at website@myonlinetraininghub.com if you want to have another go!

alaiksander says

Hi, I have a question on countifs.

My data will be to count information like age (between 7-15), and its city.

=COUNTIF(A:A;”<=15")-COUNTIF(A:N7356;"<7") gives me the correct total of age between 7-15

But when I entered

=COUNTIFS(A:A;COUNTIF(A:A;"<=15")-COUNTIF(A:A;"<7");A:A;B)

excel 2007 gave me error. Will it be possible to count it this way? thanks.

PS:

B = a cell contains city name

Mynda Treacy says

Hi,

You need to do it like this:

=COUNTIFS(A:A,">=7",A:A,"<=15",B:B,"City Name")

Kind regards,

Mynda.

alaiksander says

Thanks for your quickest reply, It really means a lot of hours to me.

Dee says

hello,

I have a formula problem.

I need to count 2 columns, with 2 different criteria, on a different spreadsheet, and have the results end on my last page for graphing purposes.

=COUNTIFS(‘RAZ00302’!R:R,”WRONG STATUS”)

Thia is tracking one of the columns on the razo302 sheet but I also need to track column t. 3 items in column t need to be picked: CPSUB, B7SUB, AND E9SUB

PLEASE ADVISE ASAP—I AM SO EXCITED THAT i FOUND YOUR WEBSITE.

thank you!!!

Mynda Treacy says

Hi Dee,

Thanks for your kind words.

Try:

=COUNTIFS(‘RAZ00302′!R:R,”WRONG STATUS”)+SUM(COUNTIF(‘RAZ00302′!T:T,{“CPSUB”,”B7SUB”,”E9SUB”}))

The part in curly brackets {} is an array. Go here for more on Excel array formulas.

I hope that helps.

Kind regards,

Mynda.

Gunnar says

I rephrase my previos question to this: Why do you need a sumproduct function at the start of the formula?

Mynda Treacy says

Hi Gunnar,

The SUMPRODUCT formula is an array formula (although you don’t have to enter it using CTRL+SHIFT+ENTER), and when used with COUNTIF and INDIRECT as I have done above for Mitchel, it returns the COUNT of multiple sheets and multiple criteria.

If you’re having difficulty counting across multiple sheets then an easier solution is to put a COUNTIFS formula on each sheet and then SUM those results. If you put your COUNTIFS formula in the same cell in each sheet then summing them is quick and easy.

To SUM the same cell on multiple sheets:

1. In the cell you want your summary type =SUM(

2. Click on the first sheet tab and select the cell you want to sum.

3. Hold down the SHIFT key and click on the last sheet.

4. Press ENTER

Excel will sum the same cell for every sheet between the first sheet you selected and the last.

I hope that helps.

Kind regards,

Mynda.

Gunnar says

Dear Mynda,

I am trying to use your formula abouve for the countif on several sheets, but can’t get it to work, even if I copy it into an identical workbook.

Can you explain a bit more in detail the indirect function part of the formula, and why you use the type of signs you do:

“ ‘ ” & ” ‘ !B:B”

Thanks!

Mynda Treacy says

Hi Gunnar,

I suspect when you copied the formula from the website into Excel the double quotes ” are not formatted correctly. In the webpage above they are italicised for some reason. Try typing them into Excel again. They should then be a regular font and your formula should work.

Alternatively you can download the workbook (see links in the post above) and use the example in the file.

The INDIRECT function, as explained here creates a reference to a cell or range of cells. When referencing other sheets you need to format the reference with apostrophes.

For example references to other worksheets must be formatted like this:

=INDIRECT(” ‘your_sheet_name’!H34″)

Text in double quotes is interpreted by Excel as text (as opposed to an operator or other criteria).

The ampersand (&) joins that text together. So Excel reads ” ‘ ” & “!B:B” as (note spaces inside double quotes are for clarity. In Excel you would leave the spaces out):

‘!B:B

Effectively ignoring the double quotes and ampersand. You can read more about joining text together in my CONCATENATE tutorial.

I hope that helps.

Kind regards,

Mynda.

Katie says

Hi,

I am trying to write a countifs that says if column b is in a certain date range, count it, which I have written, but I need a second criteria that says if column has one of five location names (city, state), then count it.

Is it possible to write a countif with an “or” criteria imbedded?

I have countifs(…..E:E,OR(‘Location’!B1,’Location’!D1,’Location’!E1,’Location’!G1,’Location’!H1))

But that didn’t work. I have also tried writing out the location names instead of selecting them from a list, but that didn’t work either…

Any ideas?

Katie says

I am trying to write a countifs formula to say if anything in this column is between these dates, count it. Here’s what I have so far =countifs(Q:Q, and(“=1/1/2012”), ….etc)

I want it to say if the contents in column Q are between jan 1 and jan 31, 2012, then count it.

Any advise? Thanks!

Mynda Treacy says

Hi Katie,

I find dates used in criteria a bit frustrating and so I tend to use the serial number version of the date in my formula rather than typing in the text version. e.g.

=COUNTIFS(Q:Q,”>=40909″,Q:Q,”<=40939")

Where 40909 is the serial number for 1 Jan 2012, and 40939 is the serial number for 31 Jan 2012.

I hope that helps.

Kind regards,

Mynda.

Katie says

Great, thank you!

Jeff says

Hi Mynda,

I am creating a dashboard report using Excel 2010. I am using Conditional formatting and a countcolor functions on the sheet – these all work perfectly. I am having issues with my countif(s)? and hope you can help.

My range (I8:AM8) represents individual project milestones being “Complete” or “N/A”. I want my following countif to total the count of “Complete” and “N/A” milestones and divide that total by the total number of milestones.

=COUNTIF(I8:AM8,”Complete”)/31

HOW do I add the “N/A” to this formula? I’ve looked on-line for an hour and asked several folks without luck.

Cheers,

Jeff

Mynda Treacy says

Hi Jeff,

Thanks for your question.

There are a few ways you could do this. Here are two:

1. If you want to use COUNTIF then you’d need to add two COUNTIF functions together and then divide by 31

So, your formula would look like this:

=(COUNTIF(I8:AM8,”Complete”)+COUNTIF(I8:AM8,”N/A”))/31

2. Or you could use the SUMPRODUCT function like this:

=SUMPRODUCT((I8:AM8=”COMPLETE”)+(I8:AM8=”N/A”))/31

Click here for more on SUMPRODUCT.

If your total number of milestones is variable (i.e. the number 31) you could use a COUNTA function in it’s place to count all cells in the range I8:AM8. So your formuls would look like this:

=(COUNTIF(I8:AM8,”Complete”)+COUNTIF(I8:AM8,”N/A”))/COUNTA(I8:AM8)

and

=SUMPRODUCT(((I8:AM8=”COMPLETE”)+(I8:AM8=”N/A”)))/COUNTA(I8:AM8)

I hope that helps.

Kind regards,

Mynda.

Ibraheem says

Thank you very much Mynda for considering my question. I had got the correct results watching your other helpful hints on Youtube and hence did not check for your response and sorry for the same. But now I come across another problem because my boss wants to consider End Dates of employee as well. Suppose he joins 01 September 2011 and his End Date is 31 December 2015, what could be the changes that should be made in my formula. Please make the necessary changes in this one (=COUNTIFS(‘Master List’!$E$3:$E$3210,’Manpower Plan’!$C5,’Master List’!$K$3:$K$3210,’Manpower Plan’!$B5,’Master List’!$N$3:$N$3210,”<="&$TE$2,'Master List'!$O$3:$O$3210,TE$4,'Master List'!$AC$3:$AC$3210,$E$3).

Mynda Treacy says

Hi Ibraheem,

Remember, each criteria you add to a COUNITFS function is considered AND. e.g.

=COUNTIFS(critera_range_1,criteria_1, AND criteria_range_2,criteria_2…..and so on if required)

So, to modify your formula you just need to add another reference to your criteria range (the Master List) and the criteria of <=31 Dec 2015 like this:

=COUNTIFS(‘Master List’!$E$3:$E$3210,’Manpower Plan’!$C5,’Master List’!$K$3:$K$3210,’Manpower Plan’!$B5,’Master List’!$N$3:$N$3210,”<="&$TE$2,'Master List'!$O$3:$O$3210,TE$4,'Master List'!$AC$3:$AC$3210,$E$3,’Master List’!$K$3:$K$3210,<=TE$5)

Where TE$5 contains the date 31 Dec 2015.

I hope this makes sense. If not you can send me your Excel workbook and I can send you a specific solution. Just complete a ticket on the help desk which you'll find a link to on the contact us page.

Kind regards,

Mynda.

ibrahim says

i want to add multipale column in countifs formulas…?

Mynda Treacy says

Hi Ibrahim,

You can set your range to more than one column. e.g:

I hope that helps. If not please send your workbook to me via the help desk so I can see an example of your data.

Kind regards,

Mynda.

Ibraheem says

Hi Mynda,

I have been watching your helpful tutorials in excel these days and have been using them satisfactorily to process our company’s 5 year Manpower Cost Plan.

I have columns by Name September 2011, October 2011….

I want to place under each month no. of employees who joined before that month.

Can you help how COUNTIFS work in this?

Thanks.

Mynda Treacy says

Hi Ibraheem,

Thank you for your question. If I understand correctly you should be able to just use a COUNTA function (assuming your columns have employee names. but use COUNT if they’re listed as numbers). And assuming your month labels start in column A (jan), and you had already populated columns A-D (Jan-Apr), with D (Apr) being the current month, and you wanted to know the number of employees who joined from Jan – Mar your formula would be:

COUNTA($A:$C)

Note: this will sum the whole of columns A & C. If you’ve got cells in these columns that you don’t want to sum then you’ll need to put the exact range in e.g. COUNTA($A$2:$C$500)

I hope this helps you out.

Kind regards,

Mynda.

Riyaz Iqbal says

Hi Mynda,

I tried this for example for practice and encountered 2 problems.

1. COUNTA($A:$C) counts my headers (names of months too). Is there some way I can count entries in the whole columns except headers?

2. What if I want to maintain a running count of employees? I tried OFFSET function but wasn’t able to get it right. I added a “Employee count” column to the right.

COUNTA(A: column to the left of Employee count) is what I tried. For “Column to the left of Employee count” I tried OFFSET(D:D,0,-1,height,1) I am facing problems with height here. I don’t know how many employee entries will be there in future.

How can I solve this height issue when I know that the column I am interested in is of dynamic height?

Regards,

Riyaz

Carlo Estopia says

Hi Riyaz,

Why don’t you send your file via HELP DESK

so we can have a good look at it.

Cheers.

CarloE

Kaushal Verma says

I have prepared My excel in this manner :

Column A Column B Column C Column D ……….

ORDER # OPERATOR QC Int. Error External Error

22120205 Nancy Chikie – –

22120207 Alex Kaushal 1 –

And so on……..

I have kept this list under one sheet named as order logged

Now I have prepared another sheet to find their daily productivity

Column A Column B Column C Column D

S.No Name 1 June 2 June ……….

1 Nancy 25 20

2 Alex 16 30

I have made a use of this formula to calculate =COUNTIF($’ORDERS LOGGED’.$B$2:$B$1000;B2)

So i would get the count of file Alex has prepared with a help of this formula which calculate data from order logged sheet.

????? But Now there are few order where in there are sub files in it say 22120207 ……is a one order but it consist of 7 other files ( with certain changes in same type) in it and Alex work on these too under the same order but his count of order is consider as one only….

when he worked on 8 files in total under one order.Which proves the report is incorrect.

So what can be done??????????

I tried this…….

Column A Column B Column C Column D ……….

ORDER # OPERATOR QC Int. Error External Error

22120207 Alex Kaushal 1 –

Alex

Alex

Alex

Alex

Alex like this kept on added his name but this is tedious….which helps to get correct count but I want to know some short way….as there is situation when in one order there are 100 files as well….Hope this will make more sense to the kind of difficulty I have.

I would really appreciate & would be glad to receive your help.

Regards,

Kaushal Verma.

Mynda says

Hi Kaushal,

Please send me the file so I can see your data.

To do this go to the Contact Us page and log a ticket. You can upload your file here.

Cheers,

Mynda.

Kaushal Verma says

Hi Mynda,

I want to know about this \ suppose there are 7 members..A/B/C/D…..

20 files are shared between them. Now I able to know how many file are prepared by C lets say 5 but if in these 5 files, there were 2 files with Copy Change, so in total he worked on 7 files. Will then this Count-if formula will work or what would the alternative?

Names

A 4

B 6

c 5 two were having sub file (copy change file).

=COUNTIF($C$2:$C$7,$B12) this help me to know that c appears 5 times but does not give me correct productivity of him ?

Please help.

Thanks,

Kaushal Verma.

Mynda says

Hi Kaushal,

Thanks for your question. I’m not clear as to whether you want Excel to track this data (whether C prepared, or copy/changed a file) or are you keeping track and entering the data and then just needing to count it?

I’ll assume the latter:

Firstly in order for Excel to count the data, you need to record it in a format it can read. If you want to use the COUNTIF then you would need to lay your data our something like this:

Column A Column B Column C

Name File Name Action (prepare, copy, change)

C xyz.xlsx prepare

A abc.xlsx prepare

C abc.xlsx change

You could then use a COUNTIFS function:

=COUNTIFS(A1:A3,”C”)

This would count every instance of “C” in the range A1:A3.

If this isn’t what you meant please go to ‘contact us’ and log a ticket on the help desk with your file so I can see exatly what you mean.

Kind regards,

Mynda.

Mynda says

Hi Glen,

I’m not 100% clear on how your data is laid out but I’ll give it a shot:

Can you not use a COUNTIF like this?:

in an empty cell in your workbook =COUNTIF(H$3:H$13,”Jan”)

and in another cell in your workbook =COUNTIF(H$3:H$13,”Feb”)

If that doesn’t ‘stop it hurting’ please log a ticket on the help desk and upload your file or an example of your data so I can see exactly what you’re trying to do.

Kind regards,

Mynda.

Lamech says

i have a similar challenge; COUNTIF(J5:J106,”Left”)

but unfortunately it does not count all the texts in that range it counts only 1/3 of the total what might be the problem?

regards

Mynda Treacy says

Hi Lamech,

I’m not sure but unless the the text in column J only says ‘left’ then it should count them all.

If there is other text with the word ‘left’ then you can append wild cards to pick up anything with ‘left’ in the cell like this:

More on Excel wildcards here.

Kind regards,

Mynda.

Glen says

I amy trying to simulate count distinct using a formula I found this morning on google: =SUMPRODUCT((H$3:H$13\)/COUNTIF(H$3:H$13,H$3:H$13&\))

I need to vary this such that I get distinct counts by month. Column A has the month as Jan, Feb…

=SUMPRODUCT((H$3:H$13\)/COUNTIFs(H$3:H$13,H$3:H$13&\,G$3:G$13,=&A3)) does not exactly give me what I need. Column H is a series of names. I want a count of distinct names in Jan, another count in Feb….

Any thoughts?

Please make it stop hurting…. I’ve been at it for 5 hours now, trying various combinations of functions in varying orders with no joy…

Glen

mitchell piedad says

I am using the formula countifs as used in the second example, my trouble is when I am trying to get a total covering more than one sheet. Each sheet layout is the same but receive #value error on previous attempts. I am expecting to get the total over 30 sheets.

Mynda says

Hi Mitchell,

You need to use SUMPRODUCT to do a 3d COUNTIFS across multiple worksheets. Using the example in my COUNTIFS tutorial above:

=SUMPRODUCT(COUNTIFS(INDIRECT(“‘”&$G$1:$G$4&”‘!B:B”),”Central”,

INDIRECT(“‘”&$G$1:$G$4&”‘!C:C”),”Doug”))

Where G1:G4 contains a list of your sheet names. You will need to put these sheet names somewhere in the worksheet you want your COUNT, and then amend the range in the formula above to suit.

You can also replace “Central” and “Doug” with cell references but remember to drop the “” and just enter the cell reference by itself.

Note: the reference to the column B:B and C:C assumes you want to count the whole column. If not just enter the exact range e.g. B2:B7 and C2:C7.

Alternatively, insert a separate COUNTIFS formula on each sheet, and then SUM the result on each sheet. e.g. =SUM(‘sheet 1:sheet 30’!D2) where D2 is the cell that contains the COUNTIFS formula on each sheet.

I hope one of these helps. Let me know how you go.

Regards,

Mynda.

Mynda says

The following question was sent in to me by Helen, but I thought I’d post my reply here for all to see:

Q. I want to count how many cells contain values between two numbers eg -0.5 and -0.25, How can I do this in excel? I use the countif function for specific values but I don’t know how to count between specific values.

A. In Excel 2007 You can use the COUNTIFS formula as follows:

=COUNTIFS(A2:A14,”>-0.5″,A2:A14,”< -0.25") In prior versions of Excel there are various ways to accomplish this, but probably the simplest is an array formula as follows =SUM((A2:A14>-0.5)*(A2:A14< =-0.25)) you have to press CTRL+SHIFT+ENTER all together to enter the SUM formula as an array. When you do this correctly the formula looks like this in the formula bar: {=SUM((A2:A14>-0.5)*(A2:A14<=-0.25))} I won't go into the logic of the array formula here, other than to say that when a SUM formula is entered as an array it gives you a COUNT instead of a SUM. Mynda.

jose aviles says

hi, I am trying to use excel with xlite soft phone. I am unable to find the formula to connect excel with xlite.. to better explain myself, i use excel to contact customers for business… i need excel to direct itself after i double click on the cube to xlite… and xlite calls for me, instead of me cpoy and past the numbers.. thanks… could some please send me the formula or an excel that already has the formula activated..

Mynda says

@jose Thanks for your question. I did a bit of Googling and found this post that offers a solution to your question. I hope it’s what you’re looking for.

http://forums.counterpath.com/viewtopic.php?f=3&t=11767&start=0

weighty says

gonna send this to my mom

Mynda says

I hope she finds it useful @weighty

John MCc says

thanks. This kinda stuff is really hard for me but you explained it really well.

gilmour says

Thanks John, glad that we are able to explain it clearly.

synkstar says

very useful for my current work

Anil kumar Pandey says

Hi Sir Please solve my problem

code 41, code 37 in a single column and in front next single column get A1, A2 i want to count how many code 41 A1 what formula used.

example given below:

SUB MRKGRD

37 92 A2

41 80 A2

37 93 A1

37 90 A2

41 93 A1

41 77 B1

41 80 A2

41 82 A2

37 82 B1

41 72 B1

41 72 B1

Catalin Bombea says

Hi Anil,

You can try this formula:

=SUMPRODUCT(($A$2:$A$12=37)*($C$2:$C$12=”A2″))

Change 37 and A2 used in this formula and the ranges to your specific data.

Catalin

Anil kumar Pandey says

Hi Sirji

Thanks for Reply

Your

=SUMPRODUCT(($A$2:$A$12=37)*($C$2:$C$12=”A2″)) is ok but my problem as it is.

i want to know for example : code is 37 in front of row A1 or A2 . When put formula answer show.

code 37 A1 is one. please give next formula . Thanking you

Catalin Bombea says

Hi Anil,

You can try this file from our OneDrive folder: Unique Count.

Hopefully it answers your questions.

Cheers,

Catalin

Anil kumar Pandey says

Hi Sirji

First i would like to Thanks.

You give reply my Question.

Anil kumar Pandey says

Hi Sir Again Pandey.

Your formula is excellent. Why doesn’t your formula get copied.

SUB MRK GRD Unique Count

37 92 A2 37A2 37A1 1

41 80 A2 41A2 37A2 2

37 93 A1 37A1 37B1 1

37 90 A2 37A2 41A1 1

41 93 A1 41A1 41A2 3

41 77 B1 41B1 41B1 3

Yes ok it is not it is not

Unique or count it is not done.know what to do. it is last. thanking you sirji

Catalin Bombea says

You’re wellcome 🙂

Catalin Bombea says

The formula in Unique column is an array formula, should be entered with Ctrl+Shift+Enter, not just Enter after editing the formula.

Catalin

ANIL KUMAR PANDEY says

Ok Sir G. Thanks a lots. if i have any problem then i again ask question. Thanks

ANIL KUMAR PANDEY says

Sirji (Array formula sheet sent me) for my knowledge.

L.E.:

Hi Sir ji i want to result for given below table. which formulas help we can get how many 41 code get A1 grade or more 37,48 and 63 same. please help me. you can do easily.

Cod MRK GRD

41 95 A1

37 67 C2

48 75 B2

37 67 C2

37 73 C1

41 48 C2

41 68 B2

37 72 C1

41 54 C1

54 59 D1

54 64 C2

48 85 A2

54 63 C2

37 63 C2

41 42 D1

48 83 A2

41 52 C1

41 59 C1

Advance Thanks

Catalin Bombea says

Hi Anil,

Please use google translate to provide clear details on what you want: https://translate.google.com/#hi/en/

You already have the OneDrive file with the formulas and a functional solution, it’s not clear what you want, take your time to write the specifications in your own language.

Thank you for understanding

Catalin