If function - multiple conditions - excel-formula

I need the final output to be based on the values on the previous 4 columns,
My table has 6 columns (A-F). Values on Column B-E depends on value A. The final output result depends on the value based on the previous 4 columns B-E.
A = has some value
B - E : lookup value and dependent on A. Can be NA or value related to A
Conditions:
If B is not NA, then B value on F
If B is NA, check C,D,E
If C is not NA, Then C value on F
If C is NA, CHECK D,E
If D is not NA, then D value on F
If D is NA, Then Check E
If E is not NA, Then E value on F
If NA, then Value on F = NA
Tried If and Or but getting error.
IF(B2<>"#N/A",B2,IF(C2<>"#N/A",C2,IF(D2<>"#N/A",D2,IF(E2<>"#N/A","REIN","NA"))))
Value to be REIN as E2 as value in it

try entering this into cell F2
=IF(ISNA(B2)=FALSE,B2,IF(ISNA(C2)=FALSE,C2,IF(ISNA(D2)=FALSE,D2,IF(ISNA(E2)=FALSE,E2,"#N/A"))))

Put this in F2:
=INDEX(B2:E2,MATCH(TRUE,INDEX(NOT(ISNA(B2:E2)),),0))
It will return the first cell that is not an error.

ok - it turns out that it is fairly tricky. Type this into F2: =IF(IF(OR(IFNA(B2,1)="NA",IFNA(B2,1)=1),"NA",B2)="NA",IF(IF(OR(IFNA(C2,1)="NA",IFNA(C2,1)=1),"NA",C2)="NA",IF(IF(OR(IFNA(D2,1)="NA",IFNA(D2,1)=1),"NA",D2)="NA",IF(IF(OR(IFNA(E2,1)="NA",IFNA(E2,1)=1),"NA",E2)="NA","NA",E2),D2),C2),B2)
I provided this answer on a comment above some time ago but wasn’t sure you saw it.

Related

VLOOKUP issue in Excel

I have the following basic VLOOKUP setup, having not used Excel in anger for a while. I am looking up the values a, b and C in a table containing two columns.
<value returned> <expected>
a 1 b =VLOOKUP(A1,C$1:D$1,1,FALSE) #N/A #N/A
b 2 c =VLOOKUP(A2,C$2:D$2,1,FALSE) #N/A 2
c 3 d =VLOOKUP(A3,C$3:D$3,1,FALSE) #N/A 3
I am getting #N/A returned for all rows (as shown to the right), but I would expect the values to the right again to be returned. Can someone please explain what I have done wrong?
Thanks
If you still stick to dataset :
a 1 b
b 2 c
c 3 d
then : =INDEX($C$2:$C$4,MATCH(A1,$D$1:$D$3,0))
So if you re-arrange the data as :
a 2 b
b 3 c
c 4 d
then use : =INDEX($C$1:$C$3,MATCH(A1,$D$1:$D$3,0))
hope that helps. (:
When using VLOOKUP, the column containing the key to be matched has to be the first column on the left of the range. So change your data layout to this:
A B C D
a b 1
b c 2
c d 3
and use the following formula:
=VLOOKUP(A1, C$1:D$3, 2, FALSE)
and then it should work. As #Scott mentioned in his comment, if you want to keep your data layout the same, you could look into using INDEX.

Excel get value that corespods to a null

I am trying to access a value in a separate column in excel which corresponds to the first empty cell in my table.
An example is
A B C D
E F G H
I J K
L M N O
i want to show "I" since it corresponds to the first null value in the 4th column.
No CSE required:
=IFERROR(INDEX(A1:A4,1/MAX(INDEX((LEN(A1:D4)=0)/ROW(A1:D4),))),"No null values")
Something like:
{=IFERROR(INDEX($A$1:$D$4, MIN(IF($A$1:$D$4="", ROW($A$1:$D$4)), 9E+99), 1), NA())}
You must use Ctrl-Shift-Enter to enter this formula

scan Excel column based on another column value

I want to check one entire column with value in another column and then assign a value in another column value to matching row cell.
Eg-
A B C D
1 10 X
2 3 Y
3 2 Z
4 11 K
What I want to do is take one value at a time from column A eg 1 and then scan through Column B if matches the Column A (value 1) then assign x to that row under D. eg if we check A3 ( value 2) with column B and found 2 is on B4 then D4 = Z. Like this I want to check all values in column in A against column B assign relevant vale from column C to Column D
How can I do this, can someone please help me.
Thanks.
Try:
= IFERROR(INDEX($C$2:$C$5,MATCH(A3,$B$2:$B$5,0)),"no match")
See below.
Try:
=IFERROR(VLOOKUP(A1,$B$1:$C$5,2,0),"")

How to fill excel column using if condition

i have 3 columns in excel sheet.Let it be A B C. In A column it contain some values Y,Y,Y,N,N,Y..... similarly in B column it has values like Y,N,Y,Y.....
My aim is to fill column C using condition If A Contains Y and B contains Y then C will be S1,S2. If A Contains Y and B Contains N then C will be S1. If A contains N and B contains Y then c will be s2.
I guess this is what you are looking for:
=IF(A1="Y",IF(B1="Y","S1,S2","S1"),IF(B1="Y","S2",""))
copy this function to C1 and drag the bottom right corner of that tab through the C column till there are entries in A and B!
=IF(AND(A1="y" , B1="y"),S1 & " " &S2,IF(AND(A1="y" , B1="n"),S1,IF(AND(A1="n" , B1="y"),S2 )
change the parameters as required...
hope this helped you!

Return value of last populated cell in variable range

Into column D, I'd like to copy the value from the last cell with data in columns E up until the column with the header "DETAIL". There might be anywhere from 2 to 15 columns from E until the column with that header, so that's where I'm stuck. So to be clear, an example:
A B C D E F G H DETAIL
1 x x x a b c d x
2 x x x x
3 x x x c b a x
3 x x x d c x
Should fill column D like so:
A B C D E F G H DETAIL
1 x x x d a b c d x
2 x x x x
3 x x x a c b a x
3 x x x c d c x
I don't mind handling this with a formula (which I couldn't come up with) or programmatically.
Create a dynamic named range by pressing CtrlF3 to bring up the Name Manager, click New, name the range something (I chose MyRange) and then use this formula to define it (Note you may need to change the Sheet name):
=Sheet1!E2:INDEX(Sheet1!2:2,MATCH("Detail",Sheet1!$1:$1,0)-1)
Then, in cell D2 and copied down, use this formula (I did not use IFERROR so that it would be backwards compatible):
=IF(COUNTA(MyRange),INDEX(MyRange,MATCH(REPT("z",255),MyRange)),"")
Here are the results (highlighted) using your provided sample data:
Please try:
=IFERROR(INDEX(F2:T2,,MATCH("zzzzzz",F2:T2)),"")
in D2 and copied down to suit.
Try using LOOKUP:
=IFERROR(LOOKUP(9^99,SEARCH("*",E1:H1),E1:H1),"")
SEARCH("*",E1:H1) returns a number when it matches any character and an error when the cell is blank. LOOKUP then returns the contents of the cells of the last number smaller than 9^99 in the array generated by SEARCH.
For example, in the first row, SEARCH("*",E1:H1) returns {1,1,1,1} so that LOOKUP returns the last 1, being d.
In the third row, SEARCH("*",E3:H3) returns {1, 1, 1, #VALUE!} and LOOKUP returns the last 1, which is a here.
This formula will work with numbers and text alike. The downside is that it is considered slower than INDEX/MATCH. On the other hand, you can modify the INDEX/MATCH to work with numbers, or modify it to work for both but becomes an array formula:
=IFERROR(INDEX(E1:H1,,MATCH(1,SEARCH("*",E1:H1))),"")
[Works with Ctrl+Shift+Enter, otherwise returns an empty cell with Enter alone]

Resources