Count cells bigger than 0, IF empty skip cell - excel

I'm having a problem writing my formula that should count all selected cells that contain a number bigger than 0 and skip the cells that are completely empty, even when the cell is selected. Excel gives me an error that I selected cells that not contain a number. How can I skip them?
This is my formula:
=COUNTIFS(C8:C12;E8:E12;G8:G12;I8:I12;K8:K12;">0")

I'm thinking you using the COUNTIFS() formula wrong, after each range, there is a criteria. You can't have multiple ranges like that to look through. For more information look here or here.
In your case you are dealing with a non continues range, and one way to deal with that would be this
So the formula would translate to:
=SUM(COUNTIF(INDIRECT({"C8:C12","E8:E12","G8:G12","I8:I12","K8:K12"}),">0"))
Another formula you could try is:
=INDEX(FREQUENCY((C8:C12,E8:E12,G8:G12,I8:I12,K8:K12),0),2)
And looking at your data, it seems as though the rest of the columns contain text (not sure, they may be dates). In case they are text values:
=SUMPRODUCT((ISNUMBER(C8:K12))*(C8:K12>0))
If they are actually dates (assuming from 2018), then you could try:
=SUMPRODUCT((YEAR(C8:K12)<2018)*(C8:K12>0))
I'm assuming this is what you looking for, instead of a VBA based solution due to the tags provided and your formula.

You could also do it in this particular case by skipping the columns that you don't want:
=SUMPRODUCT((C8:I12>0)*ISEVEN(COLUMN(C8:I12)-COLUMN(C8)))

what will be happen if you use the below formula? to you receive an error?
=COUNTIF(C8:C12,">0")+COUNTIF(E8:E12,">0")+COUNTIF(G8:G12,">0")+COUNTIF(I8:I12,">0")+COUNTIF(K8:K12,">0")

Try this
Requirement cannot be done in single formula,
combining 2 or more formula will help fixing the formula.
formula
=COUNTA(B2:B9,D2:D9) -- Count all the non blank cell's
=COUNTIF(B2:B9,"=0")+COUNTIF(D2:D9,"=0") -- Count all the cells will value as 0
Subtract both which will give the output you are looking for
Combined formula
=COUNTA(B2:B9,D2:D9)-(COUNTIF(B2:B9,"=0")+COUNTIF(D2:D9,"=0"))

Related

Using COUNTIFS in Excel, check cells (containing formulas) that are empty

Good day.
In it's basic form, I need to count how many cells are empty.
Using the following below, I can count how many cells are empty.
=COUNTIF(Sheet1!C:C,"<>")
However, if the cells in column C contain formulas, it won't work.
After some googling, I found out that using SUMPRODUCT will get what I need
=SUMPRODUCT(--(LEN(Sheet1!C:C)>0))
Now, here's my problem.
I need to use that as a criteria inside a COUNTIFS function, but I don't know how to do that because it's referencing some ranges.
So just to make it simple, using COUNTIF or COUNTIFS function specifically, how can I pass a criteria that checks if cell (with formula) is empty.
This formula returns 0 but most likely I'm just not passing it properly as a criteria.
=COUNTIF(Sheet1!C:C,SUMPRODUCT(--(LEN(Sheet1!C:C)>0)))
Happy for other ways to count cells (with formulas) which are empty, but I need to use it as a criteria for a COUNTIF/COUNTIFS function.
Thank you very much.
If I understand what you're looking for, you were pretty close already.
Following the formula's you already found you can use them like:
=COUNTIF(Sheet1!C:C,"<>")-SUMPRODUCT(--(LEN(Sheet1!C:C)>0))
It will result in the count of cells that have a value/formula minus the count of cells that show a value (blank formula result is excluded).
The result is the count of cells that contain a formula with blank result.

Find the average but without using range

Just want to ask if there is an easy way for me to find the average but not using range since the values are placed in different cells?
Here the cells and the formula that I'm using to get the average (J28+O28+T28+Y28+AD28+AI28+AN28+AS28+AX28)/9
It is working, yes. But the problem is that there is a cell that the value may be empty. For example, all of it has a value except for AS28 & AX28, so the denominator should be 6 and not 9.
Is there a way for me to easily do this? Thanks!
Just use
=AVERAGE(J28,O28,T28,Y28,AD28,AI28,AN28,AS28,AX28)
It will happily ignore empty and non-numeric cells
Note: your cells list included 9 cells, so that sould be /9 right?
Use COUNTA() function to exclude empty cells. Try below formula-
=(J28+O28+T28+Y28+AD28+AI28+AN28+AS28+AX28)/COUNTA(J28,O28,T28,Y28,AD28,AI28,AN28,AS28,AX28)

SUMIF with several OR criteria

The blue cell summates to 1, but that is not correct and it should summate to more because of the row text match with B47 row. Any ideas what's wrong?
SUMIF is not supposed to work with more than one criteria (you can't check multiple criteria within one SUMIF as you tried in your formula).
This formula will calculate the right result for you: =SUM(B3:BI3*(IFERROR(MATCH(B2:BI3,B47:AL47,0)>0,0))), this is an array formula, so you need to press CTRL+SHIFT+ENTER after it.
MATCH(...): look for all students whether they are in the list with requirments (this is the part which works only as array formula)
IFERROR(...): converts #N/A errors to 0
If I am not wrong, you are trying to calculate the number of students for a particular project with skill1 and skill2.
You may also try using COUNTIFS() function. This works for multiple criteria.

how to count multiple columns using countifs

I am putting in a formula to count the number of times a quote is required Indicated by the letter Q in a given column, when I put the formula in for one column I get the correct answer, but when I want to do it for multiple columns I get zero, can anyone help please?
the formula is
=COUNTIFS(D10:D29,"=Q",G10:G29,"=Q")
Try either
=SUMPRODUCT((D10:D29="Q")+(G10:G29="Q"))
or
=SUMPRODUCT(((D10:D29="Q")+(G10:G29="Q")>0)+0)
the former will count 2 if you have Qs in both D10 and G10 - the latter only counts each row once at most, even if there are two "Q"s
countifs criteria are connected by a logical AND. so that formula is saying it must find your string in column D AND in column G. Apparently there are 0 instances of that. if you want the total number of cells with it then make it one range.
If the must be non-contiguous, use multiple countif formulas and add them
as a note, here I would change my formula back to countif, instead of countifs for backwards compatibility since I don't use the extra criteria.
EDIT: my second example was incorrect (See comments) so I removed it
Actually, what I've found is that there is a way better way instead of the sumproduct, which can result in a overly-long formula if you have 5 columns. Instead, I found that using the SUM+IF function as we use the SUMPRODUCT, will achieve the result faster and better.
=SUM(IF((E:I="ABC")*(B:B="DEF"); 1; 0))
This function returns the number of rows that contain both "ABC" and "DEF" in the defined columns.
Spread the word!

IF statements combining multiple columns

I am using excel 2010 and looking to use IF statements to add multiple columns that have both letters and numbers. I have come as far as to get all the coding in so that when one of each condition is presented they total correctly.
The problem I am having is if there is more than one of the same condition.
For example the IF statement I am using is: =IF(ISNA(MATCH("1P",C7:CO7,0)),0,1)+IF(ISNA(MATCH("2P",C7:CO7,0)),0,2) and so on.
Obviously between cells C7 and CO7 there are many cells and if more than one cell has 1P or 2P in it the additional cells are not being added and only one. How can I get my formula to recognize the condition in more than one cell?
Thanks
=COUNTIF(C7:CO7,"1P")+2*COUNTIF(C7:CO7,"2P") should get you the answer you need
Edit: Fixed formula - thanks #Andy
If you are interested in a flexible approach that allows for an arbitrary number of match values and multipliers, you could try this.
Make a little table somewhere of Match Values and corresponding Multipliers and use this array formula:
=SUM(IF($C$7:$CO$7=$A$2:$A$5,$B$2:$B$5,0))
Commit the array formula by pressing Ctrl+Shift+Enter.
Note my screen shot truncates the data range. 14 is the correct answer for the data I entered.

Resources