Capture adjacent Cell with condition - excel-formula

I have values in A column and corresponding values in B column. I need capture based on A column value I need to capture adjacent cell value which has no zeros.

In my below example:
The formula in D1 translates to:
{=INDEX(B1:B6,SMALL((A1:A6=C1)*(B1:B6>0)*(ROW(B1:B6)),COUNTIF(B1:B6,0)+1))}
Notice it's an array formula that you must enter through CtrlShiftEnter
It will return the first match that isn't zero.

Related

Excel formula to return value if two conditions are matched

I need a formula that can be pasted into cells B2:D5 in the sheet displayed in the image below. The formula should see if the value for the row in column A matches a color in row G and if the value for the column in row 1 matches a animal in row H. For all cells without a two part match it should return a blank "". If there is a two way match then it returns the numerical value in column I
Put this formula in B2, then copy across and down:
=IF(SUMIFS($I$2:$I$7,$G$2:$G$7,$A2,$H$2:$H$7,B$1)=0,"",SUMIFS($I$2:$I$7,$G$2:$G$7,$A2,$H$2:$H$7,B$1))

Capture adjacent Cell with condition Ask Question

Capture adjacent Cell with condition
I have values in A column and corresponding values in B column. I need to capture based on A column value I need to capture adjacent cell value which has no zeros.
Say we have data like:
and we want to retrieve a value from column B that corresponds to alpha in column A, but which is not 0. We can use an array formula with MATCH()to achieve this:
First place:
alpha
in cell D1 and in E1 enter the array formula:
=INDEX(B:B,MATCH(1,(A:A=$D$1)*(B:B<>0),0),1)
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.

Get row index of the nth valid numeric value in a column

I have a spreadsheet with the column A2:A7 filled as:
A2=A4=A5=< blank>; A3=3; A6=a; A7=4;
How to get the row index of the second numeric value of the column A? In this case "6" (6th row from my data set that start in A2 and refers to A7).
In the same example, if I fill A2=0, the formula should return "2".
I need to use just Excel formulas, I can't use VBAs of macro codes.
Use this:
{=SMALL(IF(ISNUMBER($A$2:$A$7)*ROW($A$2:$A$7)=0,"",ROW($A$2:$A$7)),2)-1}
The 2 close to the end will determine if you interested in the nth smallest numeric value. In this case the 2nd.
Note that it's an array formula entered through CtrlShiftEnter

Return multiple values from a range

To return a value corresponding to another cell from a range if it matches with a cell, I found Chuff's solution helpful (in
Excel - match data from one range to another and get the value from the cell to the right of the matched data ):
=iferror(vlookup(b31,$f$3:$g$12,2,0),"")
However, if there are more than one cells within the column F which match with b1, the formula returns the value of only one cell from the column G.
Could it be modified so as to attract the value of more than one cell?
Thank you!
To return multiple corresponding Vlookup values you should use this formula: =IFERROR(INDEX($B$2:$B$9,SMALL(IF($E1=$A$2:$A$9,ROW($A$2:$A$9)-ROW($A$2)+1),COLUMN(A1))),"")
Because it it an array formula, please enter it using combination of CTRL+SHIFT+ENTER . For example, if you have you lookup range in A:B column, and lookup values in D column, then please enter formula above to F1 cell, then drag it to the right and to the bottom. You should now see all instances of Vlookup next to the lookup value in D column.
If you have only values which you want to sum in case they correspond to your value in cell B31, then simply use SUMIF formula like this =SUMIF($F$3:$F$10,$B31,$G$3:$G$10) entered in cell C31.

How can I obtain a value in one column based on another column in excel?

Suppose I have two columns; A and B. each of which has 50 rows of data. I want to set the value of a third column, C, to the value of A corresponding to, say, the minimum value of B. Can I do this without writing a macro?
https://qph.is.quoracdn.net/main-qimg-7978d7e50a58000fc152952a980c09e3?convert_to_webp=true
Consider in C1:
=IF(B1=MIN(B:B),A1,"")
and copy down:
As you see, no macro is required.
If you have unique values in Column B i.e. there's only one minimum value in the column, you can use following formula. Enter this formula in Cell C1:
=INDEX(A:A,MATCH(MIN(B:B),B:B,0))
Or if you have a fixed range say till row 25, use following formula and change number of rows as required:
=INDEX(A1:A25,MATCH(MIN(B1:B25),B1:B25,0))
If you've repeating minimum value in Column B i.e. minimum value occurs more than one then try this array formula. Enter the formula in Cell C1 and drag it down till the row you want:
=IF(COUNTIF($B$1:$B$25, MIN(B:B))>=ROWS($A$1:A1),INDEX($A$1:$A$25, SMALL(IF(MIN(B:B)=$B$1:$B$25, ROW($B$1:$B$25)-MIN(ROW($B$1:$B$25))+1, ""), ROW(A1))), "")
This is an array formula so commit it by pressing Ctrl+Shift+Enter
Again if you want to use this formula for fixed rows say 25 then use following formula. Change number of rows as accordingly:
=IF(COUNTIF(B:B, MIN(B:B))>=ROWS($A$1:A1),INDEX(A:A, SMALL(IF(MIN(B:B)=B:B, ROW(B:B)-MIN(ROW(B:B))+1, ""), ROW(A1))), "")
Got the tips for array formula from here.

Resources