How to sum all cells that contains only time in excel? - excel

Some cells contains time and some of them '#VALUE!', '######' and just text.
I want to sum all cells that contains only time.
Meanwhile I wrote =SUMIF(D13:D43,"<>#VALUE!"), but it works only if the cell contains '#VALUE!'
How I can do this?

Assuming your range is from D2:D8, use the following array formula.
=SUM(IF(ISERROR(D2:D8),"",D2:D8))
To make an array formula press CTRL + SHIFT + ENTER when done writing, instead of just ENTER>

Related

Excel: dynamically calculate range next to a searched up cell

I am an occasional Excel user and stuck how to create a dynamic range.
After looking up a text in a table, how can I calculate the range next to this cell, up to the next empty row? Not using VBA.
Thanks for your help.
In H4, formula copied down :
=IFERROR(INDEX(INDEX(C:C,MATCH(F4,A:A,0)):C$1000,MATCH(G4,INDEX(B:B,MATCH(F4,A:A,0)):B$1000,0)),"")
Should you want a dynamic range,
Change C$1000 to INDEX(C:C,MATCH(9.9E+307,B:B)
and
Change B$1000 to INDEX(B:B,MATCH(9.9E+307,B:B))
Then
The H4 copied down formula become :
=IFERROR(INDEX(INDEX(C:C,MATCH(F4,A:A,0)):INDEX(C:C,MATCH(9.9E+307,B:B)),MATCH(G4,INDEX(B:B,MATCH(F4,A:A,0)):INDEX(B:B,MATCH(9.9E+307,B:B)),0)),"")
Edit :
As per Ron Rosenfeld's comment, "should B11 change to 24 and G4 change to 24"
The "Source Table" set up in Excel Table type for dynamic range growing purpose
and
The H4 formula change to :
=IFERROR(LOOKUP(9^9,Table1[price]/(LOOKUP(ROW(Table1[texture]),ROW(Table1[texture])/(Table1[texture]<>""),Table1[texture])=F4)/(Table1[length]=G4)),"")
Combining the Index() and Match() functions usually works well when using two conditions. However, you will need to fill out the entire column A with the "texture" list in order for the below formula to work.
=INDEX(<P1>, MATCH(TRUE, (<T1>=<T2>) + (<L1>=<L2>) > 1,0))
Where <P1> is your entire price column (ex. C2:C15)
Where <T1> is your entire texture column (ex. A2:A15)
Where <T2> is your texture lookup value cell
Where <L1> is your entire length column (ex. B2:B15)
Where <L2> is your length lookup value cell
Let's say that you input your texture value into cell F3, and your length value into cell F4. With the remaining columns remaining as they are in your image, you would use the following formula:
=INDEX(C2:C15, MATCH(TRUE, (A2:A15=F3) + (B2:B15=F4) > 1,0))
Now last time I had to use Index/Match I thought I had to place the formula into an array. However, the above seems to work without it.
If you notice that it's not working as expected, you can place into an array formula by clicking the cell that contains the formula, then clicking the formula box at the top. While in the formula box, simultaneously press Ctrl + Shift + Return. This should then place curly brackets around your entire formula if done properly, as such:
If you have O365 with the SEQUENCE function, you can use, for price:
=IF(G4="","",VLOOKUP(G4,INDEX($B:$C,SEQUENCE(MATCH(TRUE,ISBLANK(INDEX($B:$B,MATCH(F4,$A:$A,0)):INDEX(B:B,ROWS(B:B)-MATCH(F4,$A:$A,0))),0)-1,,MATCH(F4,$A:$A,0)),{1,2}),2,FALSE))
explanation:
get starting row:
MATCH(F4,$A:$A,0)
ending row will be the first blank row after the starting row:
MATCH(TRUE,ISBLANK(INDEX($B:$B,MATCH(F4,$A:$A,0)):INDEX(B:B,ROWS(B:B)-MATCH(F4,$A:$A,0))),0)
Construct the relevant array:
INDEX($B:$C,SEQUENCE(MATCH(TRUE,ISBLANK(INDEX($B:$B,MATCH(F4,$A:$A,0)):INDEX(B:B,ROWS(B:B)-MATCH(F4,$A:$A,0))),0)-1,,MATCH(F4,$A:$A,0)),{1,2})
The above might reduce (with wavy) to:
index(b:c,{9,10,11},{1,2}
Then it's just a matter of applying the VLOOKUP
A more understandable, but longer with more operations, formula available in O365 makes use of LET. The advantage is that one can use names which indicate what each section of the formula does.
For example:
=IF(G4="","",LET(startRow,MATCH(F4,$A:$A,0),numRows,MATCH(TRUE,ISBLANK(INDEX($B:$B,startRow):INDEX($B:$B,ROWS($B:$B)-startRow)),0)-1,
arr,INDEX($B:$C,SEQUENCE(numRows,,startRow),{1,2}),price,XLOOKUP(G4,INDEX(arr,0,1),INDEX(arr,0,2)),price))
Or, using VLOOKUP
=IF(G4="","",VLOOKUP(G4,LET(startRow,MATCH(F4,$A:$A,0),numRows,MATCH(TRUE,ISBLANK(INDEX($B:$B,startRow):INDEX($B:$B,ROWS($B:$B)-startRow)),0)-1,arr,INDEX($B:$C,SEQUENCE(numRows,,startRow),{1,2}),arr),2,FALSE))
Finally, for earlier versions of Excel, you can use this whopper where we replace the SEQUENCE function with a construct like: ROW(INDEX(A:A,firstRow):INDEX(A:A,lastRow))
=IF(G4="","",VLOOKUP(G4,INDEX($B:$C,ROW(INDEX($A:$A,MATCH(F4,$A:$A,0)):INDEX($A:$A,MATCH(F4,$A:$A,0)+MATCH(TRUE,INDEX($B:$B,MATCH(F4,$A:$A,0)):INDEX($B:$B,ROWS($B:$B))="",0)-2)),{1,2}),2,FALSE))

IF formula contains certain text for entire column

So for this excel file, I need to calculate a percent for one subject which has several rows. With this, I have thus come up with:
=IF(COUNT(SEARCH("b0021",B3:B14)), (SUM(T3:T14))/12, "no")
Column B Column T
b0021 1
b0021 0
...
b0025 1
However, this does not seem to work, as to search that ALL the cells contain this text (right now it looks that at least one cell contains the text, which is not what I want to do if it should be one for the subject).
Any ideas of how I can do this?
Thank you.
You need to edit your cell and press Ctrl + Shift + Enter to make it array formula
Your formula =COUNT(SEARCH("b0021",B3:B14)) would start showing result only if it's in brackets
{=COUNT(SEARCH("b0021",B3:B14))}
In other words just add { } to make it formula array or by pressing Ctrl + Shift + Enter while editing your formula
{=IF(COUNT(SEARCH("b0021",B3:B14)), (SUM(T3:T14))/12, "no")}
It looks from your formula that you would need to use =SUMIFS formula rather than what you have:
=SUMIFS(T3:T14,B3:B14,"b0021")/SUM(T3:T14)

Array not outputting last cell

Following on from this question:
Array that outputs cells in a column AFTER a certain point
I have made a simplified example to test the formula
=IFERROR(INDEX($A$1:$A$11,SMALL(IF(ROW($A$1:$A$11)-MIN(ROW($A$1:$A$11))>MATCH("WORD",$A$1:$A$11,0),ROW($A$1:$A$11)-MIN(ROW($A$1:$A$11))),ROWS(A$1:A1))),"")
Here is my sample data In column A, and array formula in column B (Entered with ctrl + shift + enter)
:
The array is outputting the cells that are found after the WORD. However, you can see that 10 is not being displayed by the array.
I will display if I change all ranges in the formula to A1:A12, but this is not correct surely.
What is happening here?
You need to add 1 to the row output from the small, 11 - 1 = 10, So then you need to deal with the > Match by using >= MATCH:
=IFERROR(INDEX($A$1:$A$11,SMALL(IF(ROW($A$1:$A$11)-MIN(ROW($A$1:$A$11))>=MATCH("WORD",$A$1:$A$11,0),ROW($A$1:$A$11)-MIN(ROW($A$1:$A$11))+1),ROWS(A$1:A1))),"")
Being an array formula it must be confirmed with Ctrl-Shift-Enter instead of Enter when exiting edit mode. If done correctly then Excel will put {} around the formula.

How do I use INDEX MATCH to return multiple values?

I have a 2D matrix of binary values. I'd like to find all the 1's in a row, and return their respective header in the form of an array or comma delimited string in one cell.
I could do it in VBA, but for my knowledge I wanted to know if there was a handy way to do it in Excel.
Assuming your matrix is located at B6:F12 (adjust ranges in formula and arguments as required)
Enter this FormulaArray at G7 and copy till last record
(Enter the FormulaArray pressing [Ctrl] + [Shift] + [Enter] simultaneously, you shall see { } around the formula if entered correctly)
=TRIM(CONCATENATE(
IF($B7:$B12,$B$6,""),CHAR(32),
IF($C7:$C12,$C$6,""),CHAR(32),
IF($D7:$D12,$D$6,""),CHAR(32),
IF($E7:$E12,$E$6,""),CHAR(32),
IF($F7:$F12,$F$6,"")))
This formula concatenates the result of 5 fields separated by a blank space. You'll have to add one more argument per additional field.
This standard formula will also do the trick:
=TRIM(SUBSTITUTE(CONCATENATE(
IF($B7,", "&$B$6,""),
IF($C7,", "&$C$6,""),
IF($D7,", "&$D$6,""),
IF($E7,", "&$E$6,""),
IF($F7,", "&$F$6,"")),",","",1))
Both formulas will certainly become longer as the number of fields increases, however as the formula is quite repetitive an excel formula can be used to build it.

MS Excel create virtual column to use in formula

I want to do something similar to summing 1/x from 1 to 100 without creating an extra column to help with the calculation. I want my first column to be the numbers 1 through 100. And I want a cell to show the sum of 1/x where x is each cell in the first column. Currently the only way I can think to do this is to create a second column to do 1/x for each individual cell then sum the second column. Is there any solution to doing this without having to create the second column?
Thanks!
You can use this "array formula"
=SUM(1/A1:A100)
confirmed with CTRL+SHIFT+ENTER
....or avoid array entry by using SUMPRODUCT
=SUMPRODUCT(1/A1:A100)
both versions assume you don't have zeroes (or blanks) in A1:A100
if you might have zeroes or blanks then use this array formula
=SUM(IF(A1:A100,1/A1:A100))
if you mean 1 + 1/2 + 1/3 + ... + 1/100, use following array formula (entered by Ctrl+Shift+Enter instead of just Enter):
=sum(1/row(A1:A100))
You need to use an array formula as below:
{=SUM(1/A1:A100)}
where A1:A100 contains 1 to 100
You create the array formula bu typing the formula as =SUM(1/A1:A100) and then pressing Control-Shift-Enter.
If you do it correctly the formula then shows up with the curly brackets {} but you don't enter the curly brackets yourself.

Resources