Displaying the result of a division in different cells - excel

I dont know if i asked my question correctly but
This is what i want to do
By filling the numbers in the yellow cells i want to display the numbers in green, the numbers in green are just a simple division of Quantity/Duration and the y start displaying at the column of "Start"
I know it can be easily done with visual basic, but i want to know if there is a way to do it without it.

So three formulas, one array formula and two regular formulas:
column A:
=SUM(D2:K2)
Column B will refer to column C:
=MATCH(1E+99,D2:K2)-C2+1
Column C is an array formula:
=MATCH(TRUE,(D2:K2<>0),0)
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.
Once the three formulas are in the first row. Copy/Drag them down.

Related

Excel nth smallest DISTINCT value

I have a set of values, the Small function gives me the ability to get the top 5 smallest values. but it doesnt take into account duplicates. I want to only see each value once. for example:
1 2 2 3 4 5
i want to output 1,2,3,4,5 not 1,2,2,3,4
I am putting the output into 5 different columns with the formula Small(A1:A20,[1-5])
but im not sure how to tell it to only look at each distinct value in the range
If one has access to the dynamic array formulas (currently only available to office 365 insiders) one can just put this in the first cell and the results will spill across:
=SMALL(UNIQUE(A:A),SEQUENCE(,5))
Other wise we need to use some array formula in a specific manner.
We must have something besides a number in the cell directly preceding where we put the formula in the first cell. So if I am putting the formula in C1, B1 must not contain one of the numbers as we need to refer to it.
Put this in C1:
=SMALL(IF(COUNTIF($B$1:B$1,$A$1:$A$20)=0,$A$1:$A$20),1)
Being an array formula it must be confirmed with Ctrl-Shift-enter instead of Enter when exiting edit mode. Then copy over 5 columns.
If one cannot leave the cell B1 without a number then we must get the array another way:
Put this array formula in the first cell:
=SMALL(INDEX($A:$A,N(IF({1},MODE.MULT(IF(MATCH($A$1:$A$20,$A:$A,0)=ROW($A$1:$A$20),ROW($A$1:$A$20)*{1,1}))))),COLUMN(A:A))
Being an array formula it must be confirmed with Ctrl-Shift-enter instead of Enter when exiting edit mode. Then copy over 5 columns.
Here is another option and in single formula
Assume your data 1 2 2 3 4 5 put in A1:A6
B1, left blank
In C1, formula copied cross right until blank
=IFERROR(1/(1/AGGREGATE(15,6,$A$1:$A$20/($A$1:$A$20>B1),1)),"")
Edit : AGGREGATE is a function for Excel 2010 or above
Here is another option:
Formula in C1:
=SMALL($A:$A,COUNTIF($A:$A,"<="&B1)+1)
Drag right...

Dynamic list, excel formula

I'm going crazy over this, trying to figure out how to make a dynamic array to create a smaller list from a bigger list based on a criteria. All of it needs to be dynamic because the base list will change. Have googled for two days but can't find the proper solution.
I'm a rookie creating these things. Have tried below but it doesn't work:
=IFERROR(INDEX('2.Data'!$L$3:$L$300;SMALL(IF('2.Data'!$L$3:$L$300="12378";ROW('2.Data'!$L$3:$L$300)-ROW('2.Data'!$L$3)+1);ROWS(B$2:B2)));"")
Example:
Column A
1. 12345
2. 12345
3. 12378
4. 12345
5. 12378
6. 12345
Column B (result)
1. 12378
2. 12378
Column B should have a fancy formula that gets value from column A based on criteria=ends with 78, presented without empty cells between values.
With data in column A, in B1 enter the array formula:
=IFERROR(INDEX($A$1:$A$26,SMALL(IF(RIGHT($A$1:$A$26,2)="78",ROW($A$1:$A$26)),ROW(1:1))),"")
(your version of Excel may require the ; rather than the , in the formula) and copy downward:
Array formulas must be entered with Ctrl + Shift + Enter rather than just the Enter key. If this is done correctly, the formula will appear with curly braces around it in the Formula Bar.
You can avoid the array formulas if you use a "helper" column.

Comparing comma separated numbers in cells

I am trying to compare the numbers in the Reachability Set column with the numbers in the same row of the Antecedent Set column and return the common values in the corresponding cells of the Intersection Set column.
Screenshot:
In Excel 2016 (but NOT Excel 2013), you can use the following array-entered formula.
=TEXTJOIN(",",TRUE,IFERROR(1/(1/(ISNUMBER(FIND(","&TRIM(MID(SUBSTITUTE(B2,",",REPT(" ",99)),seq_99,99))&",",","&A2&","))))*TRIM(MID(SUBSTITUTE(B2,",",REPT(" ",99)),seq_99,99)),""))
seq_99 is a Named Formula
Refers to: =IF(ROW(INDEX($1:$65535,1,1):INDEX($1:$65535,255,1))=1,1,(ROW(INDEX($1:$65535,1,1):INDEX($1:$65535,255,1))-1)*99)
To enter an array formula, after entering the formula in the cell, confirm by holding down ctrl + shift while hitting enter. If you do it correctly, Excel will place braces {...} around the formula.
Although you would think a VBA solution is required, it is actually quite simple to do this with formulae, provided you use a lot of helper columns. These can, of course, be hidden.
All you need is a number of columns equivalent to the maximum of the numerals in the sets, after each of the original columns of your table. For the example supplied, this would be 17 columns.
Here is a screenshot of the new table with the helper columns unhidden:
The follow formulae are entered into the top left cell of each coloured region and filled/copy-pasted/ctrl-entered into the rest of the cells.
Red Cells (entered into B2):
=IF(ISERROR(FIND(","&B$1&",",","&$A2&",")),0,1)
Green Cells (entered into T2):
=IF(ISERROR(FIND(","&T$1&",",","&$S2&",")),0,1)
Blue Cells (entered into AL2):
=IF(B2*T2,AL$1&",","")&AM2
And finally, the result entered into cell AK:
=LEFT(AL2,LEN(AL2)-1)
The formulae work by ensuring that all the numbers in the sets have a preceding, and trailing, comma so that they can be uniquely searched for.
Then it is a simple matter of constructing a grid for the sets where a 1 means the number exists in the set a 0 means it doesn't. Multiplying these two grids together results in the "intersection set".
Then it is a simple matter of reconstituting the result strings.
Caveat:
This solution won't work correctly if there are any spaces in the "Set" data. To overcome this you need to use the SUBSTITUTE() function.

How to sum several bracket-surrounded numbers of a single cell with Excel formula?

I have one cell containing several lines, including numbers inside brackets, which I want to sum-up with a single Excel formula (no VBA).
The following approach already works for single bracket:
https://exceljet.net/formula/extract-text-between-parentheses
But I need extended approach... here an example for the content of one single Excel cell to which I search for an formula, which should result in sum of "8":
The task requires following effort (incl. documentation)
- create plan (2h)
- execute test (14h)
- write report (draft) (2h)
Possible approach: The formula should search for all numbers inside the mask <"(" x "h)">, where x must be summed-up.
UPDATE: The formula should also work with numbers >=10.
UPDATE2: It should also work in case there are other comments in brackets, also after presence of first (xh) number. See "(draft)" in example, last row.
Borrow the formula from this post #6 (https://www.mrexcel.com/forum/excel-questions/362184-extracting-multiple-numbers-string.html) and modified to fit your need (single cell formula). Assuming you are going to enter the formula in cell B1:
{=SUM(VALUE(MID(0&A1,LARGE(ISNUMBER(--MID(A1,ROW(INDIRECT("1:"&LEN(A1))),1))*ROW(INDIRECT("1:"&LEN(A1))),ROW(INDIRECT("1:"&LEN(A1))))+1,1)))}
Basically this is to assign each character with its index and then get the numeric value to sum up. Please note this is an array formula. Please click Ctrl + Shift + Enter together.
REVISED:
Here is the array formula (click Ctrl + Shift + Enter together) to extract two-digit numbers:
{=SUMPRODUCT(IFERROR(0+("0"&TRIM(MID(SUBSTITUTE(SUBSTITUTE(S‌​UBSTITUTE(LOWER(MID(‌​‌​A1,SEARCH("h)",A1)‌​-4,LEN(A1))),"h","")‌​,")","("),"(",REPT(" ",1000)),ROW(INDIRECT("1:20"))*2*1000-999,1000))),0))}
What this does is to massage the text first by removing unnecessary content, remove h wording and convert ) to 999 blanks. Then you can extract numbers and add up. IFERROR will made the anything not numbers to 0. Hope this can solve your problem.
I appreciate that this is not in any way elegant, however it is working. I do not have time to run through the logic here right now (might edit it in later though) but essentially it is a load of search index logic.
I have Used 5 columns for each formula which assumes a maximum of 5 values but you can adjust this as needed by dragging the formula over more columns as it will begin looking for the next "(?h)" after the previous column's found value.
Red cell formula: =SEARCH("(?h)",$A1)&" - "&SEARCH("h)",$A1)
Orange cell formula: =SEARCH("(?h)",$A1,MID(B1,SEARCH("- ",B1)+2,LEN(B1)-(SEARCH("- ",B1)+1))*1)&" - "&SEARCH("h)",$A1,MID(B1,SEARCH("- ",B1)+2,LEN(B1)-(SEARCH("- ",B1)+1))+1)
Yellow cell formula: =MID($A1,LEFT(B1,SEARCH(" - ",B1))+1,((MID(B1,SEARCH("- ",B1)+2,LEN(B1)-(SEARCH("- ",B1)))*1)-(LEFT(B1,SEARCH(" - ",B1))*1))-1)*1
Green cell formula: =SUMIF(G1:K1,">="&0)

Average of top 10 values in a row, treating empty cells as ones

Suppose I have a row in excel consisting of n cells (in fact n=12). Some of these cells have numerical values, some may be empty. I want to find the average of the top m cells in the row (in fact m=10), treating the empty cells as if they contained 1s.
(The context for this is that I want to compute the average grades of some students whose homework I grade, and this is the formula used in the course. The empty cells correspond to homeworks which were not handed in, but I would like to keep the distinction between homeworks graded 1 and those missing.)
Based on data in A1:L1, array formula**:
=AVERAGE(LARGE(IF(ISNUMBER(A1:L1),A1:L1,1),{1,2,3,4,5,6,7,8,9,10}))
Regards
**Array formulas are not entered in the same way as 'standard' formulas. Instead of pressing just ENTER, you first hold down CTRL and SHIFT, and only then press ENTER. If you've done it correctly, you'll notice Excel puts curly brackets {} around the formula (though do not attempt to manually insert these yourself).
Put the 12 items in cells B1 thru M1. In B2 enter:
=IF(B1="",1,B1)
and copy across. In A1 enter:
=LARGE($B$2:$M$2,ROWS($1:1))
and copy down. Now to get the average of the top 4 grades, simply pick a cell and use:
=AVERAGE(A1:A4)
To get the top 5, use =AVERAGE(A1:A5), etc.
Well, it can be done slightly less complicated than arrays, by just splitting the average into its parts, the sum and the division.
=(sum(B2:K2)+countif(B2:K2,0))/10
This is for scores horizontally starting in the B2 row. You sum the scores, then count the zeroes (which is what you want to add to the sum). Then divide by m.

Resources