I need to count all cells with a certain length of FORMULATEXT(), I decided to go for SUMPRODUCT() as I believe you can't count by length while using COUNTIF(). The formula that I use while counting cells of certain length is this one:
=SUMPRODUCT(--(LEN(AV3:AV201)<>7))
Adding the FORMULATEXT() function resulted in error.
VBA is unfortunately out of question as our accounting system can't recognise .xlsm files.
Try this array formula with CSE,
=SUMPRODUCT(--(IFERROR(LEN(FORMULATEXT(AV3:AV201)), 7)<>7))
If FORMULATEXT sees text, numbers or a blank cell, it returns #N/A. IFERROR can return those as LEN 7 so they are not included in the count.
Without compensating for errors, your formula will only work if AV3:AV201 contains a formula in each cell.
Related
I have 4 character cells that contain a "number" in positions 1 and 4, and a character in positions 2 and 3. I want to get a numeric sum of the numbers for positions 1 and 4 for the range of cells.
My cells look like this:
I have tried SUM(MID(VALUE(B4:B21,1,1)) which gives me an invalid type error
Also tried SUM(MID(B4:B21,1,1)*1) which works with a single cell but not for a range.
=SUM(IFERROR(1*MID(B4:B21,{1,4},1),0))
OR
=SUMPRODUCT(IFERROR(1*MID(B4:B21,{1,4},1),0))
If you have Excel O365 with dynamic arrays, then the first formula will work OK.
If you have an earlier version, you may need to either confirm the first formula as an array formula with ctrl+shift+enter, or use the second formula entered normally.
The IFERROR takes care of any values in the range that do not have the pattern of [0-9][A-Z][A-Z][0-9] If you would prefer to detect that by returning an error, just remove the IFERROR part of the formula:
=SUM(1*MID(B4:B21,{1,4},1))
SUMPRODUCT of LEFT and RIGHT
=SUMPRODUCT(VALUE(LEFT(B4:B21,1)))+SUMPRODUCT(VALUE(RIGHT(B4:B21,1)))
With error handling included, but possibly (Excel 2019) confirming with CTRL+SHIFT+ENTER:
=SUMPRODUCT(IFERROR(VALUE(LEFT(B4:B21,1)),0))+SUMPRODUCT(IFERROR(VALUE(RIGHT(B4:B21,1)),))
I have a column in a spreadsheet in which numbers are sometimes
stored in text format or are mixed with text values.
For converting them to numbers I would
normally use VALUE. And because of the other text values in the same column I would additionally wrap it
with IFERROR, defaulting the result to 0 to prevent any issues with the
conversion.
All this I wanted to use in SUMPRODUCT and I am reluctant to add any new intermediate columns to the sheet.
I face an issue with IFERROR returning a single value (or even a #VALUE! error) when it is used in SUMPRODUCT as one of the arrays. What's even worse, the sum is correctly assessed in the Function Arguments window.
I created an isolated case, that you can see here SUMPRODUCT using IFERROR problem. One of the numbers in column C is preceded with with single quotation "'" and the C column holds both text and number values.
A long version of the SUMPRODUCT formula
=SUMPRODUCT(IFERROR(VALUE($C1:$C4),0),--($D1:$D4="yes"),--NOT(ISERROR($C$1:$C$4+1-1)),--(($C1:$C4)<>"")) and the simplified one =SUMPRODUCT(IFERROR(VALUE(C19:C21),0)). It returns a correct number in the Function Arguments window when in the spreadsheet it shows #VALUE! error or respectively an incorrect sum.
I wonder if I am using the aforementioned functions wrong (can't IFERROR be used as an array here?), or is this some sort of an Excel bug (why the assessed value is different from the result in the spreadsheet?).
Thanks in advance for your comments and suggesting a solution.
Your formula :
=SUMPRODUCT(IFERROR(VALUE($C1:$C4),0),--($D1:$D4="yes"),--NOT(ISERROR($C$1:$C$4+1-1)),--(($C1:$C4)<>""))
and
=SUMPRODUCT(IFERROR(VALUE(C19:C21),0))
all need to be confirmed with Ctrl+Shift+Enter
Another option,
Change your formula into :
=SUMPRODUCT(N(+$C1:$C4),--($D1:$D4="yes"),--NOT(ISERROR($C$1:$C$4+1-1)),--(($C1:$C4)<>""))
and
=SUMPRODUCT(N(+C19:C21))
the change using N(+.... instead of IFERROR(VALUE(....
also, the above 2 formulas need not array entry
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"))
I am trying to get a sumproduct function to average a column based on criteria in prior adjacent columns.
The column i am trying to average is calculated from a formula that has an IFERROR to return a blank if there is an error.
=IFERROR(A5*B3,"")
some of the cells in that column containt the blank generated by the if error statement, my sumproduct is giving a #value error when it tries to average the range with the blank. I want it treated as nothing not as 0
Is there anyway around this or should I try to recreate my sumproduct using some sort of averageifs function?
This is the sumproduct in question:
=SUMPRODUCT((Data!$KM$7:$OV$7=C$7)*(Data!$KM$9:$OV$118>=$B10)*(Data!$KM$9:$OV$118<=$A10)*(Data!$BLW$9:$BLW$118))/SUMPRODUCT((Data!$KM$7:$OV$7=C$7)*(Data!$KM$9:$OV$118>=$B10)*(Data!$KM$9:$OV$118<=$A10))
Try this array formula instead:
=AVERAGE(IF((Data!$KM$7:$OV$7=C$7)*(Data!$KM$9:$OV$118>=$B10)*(Data!$KM$9:$OV$118<=$A10)*(Data!$BLW$9:$BLW$118<>""),Data!$BLW$9:$BLW$118))
Being an array it needs to be confirmed with Ctrl-Shift-Enter when leaving edit mode. If done properly excel will put {} around the formula.
The reason SUMPRODUCT will not work is it tries to multiply a string, albeit an empty string but a string none the less, with numbers, which will throw an error.
The array formula ignores all the empty string cells and skips them.
The formula =IFERROR(A5*B3,"") puts a "" in the cell. This is not a value, so formulas using this cell won't work. You need to turn it to a numeric value even though it is blank
Use =value(IFERROR(A5*B3,""))
=SUMPRODUCT(P10,M10,L14,L13). This could be easy. We have to write what we want to do rather it is sum, product, division or subtract
I've put together an Excel spreadsheet to keep track of employees' time off using an array formula. The formula works for date ranges that are entered as "mm/dd - mm/dd", but I'd like it to also support single dates "mm/dd". However, I get a #VALUE! error when one of the cells in the range is of this format, even though the formula supports both formats when not entered as an array formula.
Example:
With the value "11/28" in cell B2, and a table of holidays in B31:B37, the following formula accurately calculates the number of work days as 1.
=SUM(IF(ISBLANK(B2),0,(IF(ISERR(FIND("-",B2)),NETWORKDAYS(B2,B2,$B$31:$B$37),NETWORKDAYS(LEFT(B2,5),MID(B2,FIND("- ",B2)+2,5),$B$31:$B$37)))))
If the value of B2 is "11/28 - 12/03", the formula returns 4.
I want this formula to work over a range of of cells for each employee, so I expand the range from "B2" to "B2:B10", and enter as the following array formula:
=SUM(IF(ISBLANK(B2:B10),0,(IF(ISERR(FIND("-",B2:B10)),NETWORKDAYS(B2:B10,B2:B10,$B$31:$B$37),NETWORKDAYS(LEFT(B2:B10,5),MID(B2:B10,FIND("- ",B2:B10)+2,5),$B$31:$B$37)))))
This formula works fine when every cell in the range is blank or has a date range of "mm/dd - mm/dd". However, if one of the cells has a single date "mm/dd", it throws a #VALUE! error.
What am I missing?
If there is no "-" in a given string then the FIND function will return a #VALUE! error for that string.
In general, there are two ways to resolve such issues. One is to include an error trap; the other, slightly longer though perhaps nevertheless preferable (IFERROR clauses are generally best avoided if possible), is to make suitable amendments to the strings being passed to MID and FIND such that this combination of functions does not error, whilst also ensuring that correct results are returned.
One such solution (still array-entered) is:
=SUM(IF(B2:B10<>"",NETWORKDAYS(LEFT(B2:B10,5),MID(B2:B10&"- "&B2:B10,FIND("- ",B2:B10&"- ")+2,5),$B$31:$B$37)))
Regards