Is there a way to calculate the count of items in a range, that are a formula?
I'm only expecting =TEXT formulas, so I tried =COUNTIF(1:1, "=TEXT"), but that didn't work. Seems CountIf only operates with the displayed values of the cells.
If I have understood your post clearly, specifically you need those functions which starts TEXT() then perhaps you could try :
• Formula used in cell F6
=SUM(N(IFERROR(LEFT(FORMULATEXT(D6:D19),6)="=TEXT(",0)))
If you have the following in cells A1:A5
=TEXT("493","DDD")
555
=TEXT("420000","YYYY")
Yep
Nope
Either of these formulas should give a result of 2
Counts formulas
=SUMPRODUCT(--ISFORMULA(A:A))
Counts Cells with Formula Text
=SUMPRODUCT(--ISNUMBER(SEARCH("text(",FORMULATEXT(A:A))))
Related
I want to count the number of cells that meet two conditions:
sheet ABC's A2:A100 should be equal to the value of sheet XYC cell A8
the cell value in range D2:M100 = 1
Originally, I tried to use this formula:
=COUNTIFS(ABC!$A$2:$A$100,XYC!A8,ABC!$D$2:$M$100,1)
But this gave me error #VALUE
I then decided to use the following formula to count each column separately and add them together.
=COUNTIFS(ABC!$A$2:$A$100,XYC!A8,ABC!$D$2:$D$100,1)+
COUNTIFS(ABC!$A$2:$A$100,XYC!A8,ABC!$E$2:$E$100,1)+
COUNTIFS(ABC!$A$2:$A$100,XYC!A8,ABC!$F$2:$F$100,1)+
COUNTIFS(ABC!$A$2:$A$100,XYC!A8,ABC!$G$2:$G$100,1)+
COUNTIFS(ABC!$A$2:$A$100,XYC!A8,ABC!$H$2:$H$100,1)+
COUNTIFS(ABC!$A$2:$A$100,XYC!A8,ABC!$I$2:$I$100,1)+
COUNTIFS(ABC!$A$2:$A$100,XYC!A8,ABC!$J$2:$J$100,1)+
COUNTIFS(ABC!$A$2:$A$100,XYC!A8,ABC!$K$2:$K$100,1)+
COUNTIFS(ABC!$A$2:$A$100,XYC!A8,ABC!$L$2:$L$100,1)+
COUNTIFS(ABC!$A$2:$A$100,XYC!A8,ABC!$M$2:$M$100,1)
I am wondering if there are any other ways that allows me to shorten my formula?
Thank you.
You can use a boolean structure inside SUMPRODUCT() or just SUM() if your version of Excel supports dynamic arrays (ms365):
=SUMPRODUCT((ABC!A2:A100=XYC!A8)*(ABC!D2:M100=1))
I want to get the count of cells used in an excel function.
For example say I have a sum function ='CV'!D11+Farmer!D11+'County'!D11+Rt!D11+WT!D11+'Country'!D11
I need a function that will tell me how many cells were used to get the total sum. In this case it is 6. The tricky part is if one of the cells used is blank I do not want it counted. For instance say cell D11 on the Farmer sheet is blank I do not want it counted in the total. So the total should be 5.
Use COUNT:
=COUNT('CV'!D11,Farmer!D11,'County'!D11,Rt!D11,WT!D11,'Country'!D11)
It will only count the cell if it has a number
You should really try to collate all your data in to a single sheet before running calculations. For the sake of example, I'll assume you have it in the range A1:A5, then you can add handling of the various cases using array formulas:
Get the count of non-empty cells (the ISBLANK function is untrustworthy in my experience): {SUM(IF(LEN(A1:A5)>0,1,0))}
Get the sum of those cells: SUM(A1:A5)
(must use Ctrl+Shift+Enter to enter the formula as an array formula, you will know it worked if the formula shows like {IF(...)} with the curly brackets)
Because blank/missing values are treated implicitly as 0 in the SUM function, this case is simple. If you have other validations then you'd have to write an array formula for the summation as well. For example, only including numbers between a min and max threshold (e.g. if you want to exclude outliers):
{SUM(IF(AND(A1:A5 >= yourMinValue, A1:A5 < yourMaxValue), A1:A5, 0)}.
If I understand your question correctly, you want to literately count the number of cells used in a formula which in your example is summing 6 values from 6 different locations.
I used the following example to demonstrate my solution:
The sum of =A1+B1+C1+D1+E1+F1 is 10 where cell C1 has a 0 value in it but cell E1 is blank.
Using the following array formula I was able to count the number of cells that have a value other than 0:
=SUMPRODUCT(IFERROR(ABS(N(INDIRECT(TRIM(MID(SUBSTITUTE(RIGHT(FORMULATEXT(A3),LEN(FORMULATEXT(A3))-1),"+",REPT(" ",100)),100*ROW(INDIRECT("1:"&LEN(FORMULATEXT(A3))))-99,100)))))>0,0)*1)
Please note you MUST press Ctrl+Shift+Enter upon finishing the formula in the formula bar otherwise they will not function correctly.
The logic is to use a combination of TRIM+MID+SUBSTITUTE+RIGHT+FORMULATEXT+REPT+ROW+INDIRECT to extract the cell addresses from the original formula, then use INDIRECT to convert the cell address into the values stored in those cells, then use a combination of IFERROR+ABS+N to find out if any of these values are not 0, and lastly use SUMPRODUCT to add up all the TRUE results.
It is obvious that there are a couple limitations of my solution:
If your actual formula is not strictly in the form of A+B+C+D+E+F, then my SUBSTITUTE part of formula will need further modification;
The formula will treat cells containing 0 as blank and does not include them in the count.
Let me know if you have any questions. Cheers :)
Currently using the following forumlas to count the number of records in all of column Z that does not have #N/A but it does not work. All the rows in Column Z have a formula itself (Which is why some of them display #N/A, its a VLOOKUP).
=COUNTA(Z:Z)-SUM(IF(ISNA(Z:Z),1))
=SUMPRODUCT(--(TRIM(Z:Z)<>"#N/A"))
These return a "0" value which is not true, what am I doing incorrect?
If you are using Excel 2010 or later, to count non-error values you can use (regular formula)
=AGGREGATE(3,6,Z:Z)
No reason to use an array formula for this, you can just do something like
=COUNTIFS(Z:Z, "<>#N/A",Z:Z, "<>")
or
=COUNTA(Z:Z) - COUNTIF(Z:Z,"=#N/A")
The first one counts every nonblank, non #N/A cell. The second does what you're trying to do now and subtracts the total of #N/A cells from the total of every nonblank cell. Maybe using ISNA is technically more correct or faster, but this probably works just as well for most cases.
This array formula sums the cells of range Z:Z that are not NA's :
=SUM(IF(NOT(ISNA(Z:Z)),Z:Z)) Ctrl+Shift+Enter
This one (which is probably what you want) sums all but errors:
=SUM(IF(NOT(ISERROR(Z:Z)),Z:Z)) Ctrl+Shift+Enter
And another (simpler) one
=SUM(IFERROR(H:H, 0)) Ctrl+Shift+Enter
Are you entering it as an array formula? Press Ctrl-Shift-Enter instead of just enter. I think the first formula should work.
=COUNTA(Z:Z)-SUM(IF(ISNA(Z:Z),1))
I have a situation where I need to calculate ontime vs. late in a range of cells.
I use the if statement =IF(N2>K2 +30,"Late","") and this works fine however I would like to combine the countif statement to count the range of cells that contain "late"
Thanks
Try this:
=SUM(IF(N:N>K2+30,1,0))
Enter it as array formula by pressing CTRL+SHIFT+ENTER.
updated if you only need to count the number of lates.
As per Roberto's comment, if you are actually using a formula to put "Late" in column L for each relevant row you can use a simple COUNTIF to count those
=COUNTIF(L:L,"Late")
or if you want to use the source data in column N just use COUNTIF with that
=COUNTIF(N:N,">"&K2+30)
I have two columns of numbers. Both are 1 to 5. I want to count all the cells where the left column value equals the right column value AND the left column value equals a certain value.
I tried this:
=SUM(IF(W2:W13=X2:X13 AND W2:W13=4,1,0))
I've tried pressing Ctrl+Shift+Enter and it adds {} around the formula but that didn't help either.
I think it's the W2:W13 = 4 part that doesn't work
=COUNTIFS(W2:W13,"=4", X2:X13, "=4")
You can use the sumif() function:
SumIf( range, criteria, sum_range )
it will apply the criteria for each row in the range.
Edit: to count the matches, you can use sum_range = 1 or use the Countif() function suggested by Ben in his answer
Have you considered a third column (C) with the formula IF(A1=B1,1,0) and then summing that third column?
I'm not much of an Excel Expert, but didn't they craeted the COUNTIF(range, criteria) function for this?
Add a third column eg Z2:Z13 with this formula: IF(AND(W2=X2; W2=4); 1; 0)
Then sum that one.
I don't have Excel 2007. So here's how you can do it in Excel 2003:
=COUNT(IF((W2:W14=4)*(X2:X14=4),Y2:Y14))
Since you are looking for a specific value and the column next to it to be the same value, you can just compare both columns to the same value.
The trick to get this to work is after entering the formula you need to hit F2 to go into edit mode and then hit CTRL-SHIFT-ENTER which makes this formula an array formula. This will put {} around the entire formula. Without making this an array formula this formula won't work.
I found this information in the Excel help document titled Count how often a value occurs