I have a list of comma-separated numbers (positive,single or double digits) in A1.
The list can only contain up to 20 numbers, can be less but not more.
Is there a formula to count the even and odd numbers in the cell without separating the list in to different cells? Thanks.
For Even:
=SUMPRODUCT(--ISEVEN(--MID(SUBSTITUTE(A1,",",REPT(" ",99)),(ROW($XFD$1:INDEX($XFD:$XFD,LEN(A1)-LEN(SUBSTITUTE(A1,",",""))+1))-1)*99+1,99)))
Odd:
=SUMPRODUCT(--ISODD(--MID(SUBSTITUTE(A1,",",REPT(" ",99)),(ROW($XFD$1:INDEX($XFD:$XFD,LEN(A1)-LEN(SUBSTITUTE(A1,",",""))+1))-1)*99+1,99)))
The quantity of odd numbers (put this in cell B1):
=SUMPRODUCT(MOD(MID(SUBSTITUTE(A1,",",REPT(" ",LEN(A1))),1+LEN(A1)*(ROW(INDIRECT("1:"&LEN(A1)-LEN(SUBSTITUTE(A1,",",""))+1))-1),LEN(A1)),2))
The quantity of even numbers (references the result of the previous formula, which is assumed to be in cell B1):
=LEN(A1)-LEN(SUBSTITUTE(A1,",",""))+1-B1
Related
My worksheet contains orders from clients. The orders are all wooden panels.
Every order is assigned a number which is led by the letter Q.
Column B contains the number of parts in the order.
Column C contains the total m² in the order.
Orders that contain one or more parts that are 2.8 x 0.0735 m will get a row of their own.
I'm trying to count the number of times that this part occurs in a list of more than a thousand rows.
So if I divide the total m² by the m² of the part I'm looking for and divide this by the amount of parts in the order, I should get exactly 1 as a result.
If I take the sum of all the number of parts that result in a 1, I get my total.
Now I'd like to put this in one formula for the entire worksheet, but SUMIF doesn't work the way I'm trying. (It's in Dutch)
=SOM.ALS(B:B;(C:C/(2,8*0,0735)/B:B)=1)
I can't seem to use this formula as a criterium in the SUMIF.
For now I use a helping column that gives the right amount per row. Then take the total SUM of these.
Is it possible to put this in a single formula?
Yes, it is possible. Try this one:
{=SUM(--(B:B=C:C/(2.8*0.0735))*IF(ISERROR(1/B:B),0,1))}
Remember to enter it as an array function with CNTRL + SHIFT + ENTER.
The first half of the formula is just a logical test, after the asterisk it tests if 1/B results in an error (thereby omitting text, zeroes, and blanks) and returns a zero if there is an error.
These are then summed and the result displayed.
In Dutch and English:
{=SOMPRODUCT(--(B:B=(ALS(ISTEKST(C:C);1;C:C))/(2,8*0,0735));B:B)}
{=SUMPRODUCT(--(B:B=(IF(ISTEXT(C:C),1,C:C))/(2.8*0.0735)),B:B)}
is working perfectly. (Enter with Ctrl-Shift-Enter)
The first bit is the logical test, which will check if B:B = C:C / (2.8*0.0735)
It got stuck on #VALUE! because there is text in C:C.
The IF(ISTEXT)) eliminates text by converting them to numeric values, in this case 1, but it can be any numeric value.
The logical test will return TRUE(1) or FALSE(0) because of the double dash or unary operator and this will be multiplied by their respective B:B value.
Because the row with text has no value in B:B, it will result as zero.
Trying to figure out how to count the number of leading zeros in an excel cell. The value within the cell can be comprised of both numbers and letters or just numbers or just letters. The column is formatted as a text column.
So far I have been able to use
=MIN(FIND({1,2,3,4,5,6,7,8,9},A1&"123456789"))-1
This gets me all the leading zeros correctly for cells containing only numbers but when it is a combination of both digits and letters it also counts the letters.
eg. 00012 = 3 (correct) 000ab = 5 (should be 3)
Is there a way that I can adapt this formula to not count letters?
Try:
=SEARCH(LEFT(SUBSTITUTE(TEXT(A1,"#"),"0",""),1),A1)-1
Try looking for the first digit/character that isn't a zero and subtract 1.
=AGGREGATE(15, 7, ROW($1:$9)/(MID(A2, ROW($1:$9), 1)<>"0"), 1)-1
We need to count how many occurrences of each number are in a cell over a range of cells in the same column and output a tally of the totals for each number. See the attached picture and the desired output in the column next to it. We tried other formulas found online in both excel and open office with no results.
letter Count
Working Count
Try the following formula in D1:
=LEN(TEXTJOIN("",TRUE,A:A,"#"))-LEN(SUBSTITUTE(TEXTJOIN("",TRUE,A:A,"#"),C1,""))
and populate down.
(you will need 2016 or later for TEXTJOIN)
Option 1
Single array formula (ctrl+shift+enter !) which will work for strings with a maximum length of [5] alphanumeric characters (but you can easily modify the formula by adding a few numbers in the hard-coded array constant {1,2,3,4,5}):
{=SUM(N(MID($A$1:$A$500,{1,2,3,4,5},1)=TEXT(C3,"#")))}
You can add some further trickery to let Excel define the array constant, so the formula will work for any length of the string of digits :
{=SUM(N(MID($A$1:$A$500,
COLUMN(INDIRECT("A1:"&CHAR(65+MAX(LEN($A$1:$A$500)))&"1"))
,1)=TEXT(C3,"#")))}
The part in the middle (COLUMN()) creates the {1,2,3,4,5} array. You might have seen other versions of this formula, without the CHAR, which I use to create a reference to e.g. cell E1 (knowing that 65 is the code for "A").
.
Option 2
This array formula (ctrl+shift+enter !) works in all Excel versions, but is not very "elegant" as you have to repeat the key part of the formula as many times as the maximum digits you have in your cells (this example is for max 3 characters):
{=SUM(
N(MID($A$1:$A$500;1;1)=TEXT(C3;"#"))+
N(MID($A$1:$A$500;2;1)=TEXT(C3;"#"))+
N(MID($A$1:$A$500;3;1)=TEXT(C3;"#")) )}
The character you are counting is in C3. This will work for numbers and letters. If you can have five alphanumeric characters, you have to add two more N(...) parts, and replace the second parameter of the MID function with 4 and 5 respectively.
I'm trying to write a SUM(IF(zero, add 8), A1:G1) kind of excel function.
What it should do:
If the cell contains a number, add that number to the sum.
If the cell contains a number = 0, add 8 to the sum.
if the cell is empty, add nothing to the sum
I have tried using SUMIF, but it only "adds the numbers if they meet a criteria", and I rather need "add this when the criteria is met"
You could just make a longer formula:
=SUM(A1:G1)+COUNTIF(A1:G1, 0)*8
The first sum will only do your numbers ignore blanks and 0's, the second part counts the number of 0's and multiplies it by 8.
You can do this with the following formula:
=SUMIF(A1:G1,">0")+8*COUNTIFS(A1:G1,0,A1:G1,"<>")
should be self-explaining :)
Method 1
If you can spare another column, just use an IF statement to replace all 0's by 8's and blanks by 0's (not really necessary) in a new column
=IF(A1=0,8,A1) and take a SUM of this column.
Method 2
Just SUM over your original data, count the number of zeros in your data and multiply this number by 8.
=SUM(A1:A10)+8*COUNTIF(A1:A10,"=0")
Note: The data is in A1:A10 in this case.
I am trying to find a function that will return the number of cells within a given range that have a number in them. I want to count the number of responses that people gave, irregardless of the value they entered in the cell.
How do I do this?
If you are looking for a number of cells containing numeric values, then COUNT() function is what you're looking for:
=COUNT(A1:D6)
If you are looking number of cells with non-blank values (numeric or otherwise), then COUNTA() is the right function:
=COUNTA(A1:D6)
The last formula works only if none of the cells have empty strings as values (i.e. none of the cells in the range have ="" or something equivalent in them). If that is the case, then this formula should be used instead:
=SUMPRODUCT((E7:G10<>"") * 1)
You can use the LEN function to find the length of the input of a cell, and then test if it's greater than zero or not.
=LEN(A1)>0
You have to use count to count the number of numbers:
=COUNT(Your_range)
Count will not count the number of cells that do not have a number (but those don't count do they?)