Excel lookup previous/above value when value matches - excel

please help me. basically the 2 formulas works separately, but doesn't work when I combine them:
In cell A2 I have this formula:
=ROW(INDEX(Sheet2!$A$2:$A$7512,MATCH(Sheet3!H2,Sheet2!$A$2:$A$7512,0)))
This formula gets matches a value from another sheet and get its row number.
In cell B2 I have this formula:
=LOOKUP(2,1/(LEFT(INDIRECT("Sheet2!A2:A"&A2),2)="FA"),INDIRECT("Sheet2!A2:A"&ROW(INDEX(Sheet2!$A$2:$A$7512,MATCH(Sheet3!H2,Sheet2!$A$2:$A$7512,0)))))
This formula starts with the range from A2 and finds the last previous value starting with "FA".
This works fine.
But When I copy/paste A2 into B2, I get #N/A (bold part is what I pasted).
=LOOKUP(2,1/(LEFT(INDIRECT("Sheet2!A2:A"&ROW(INDEX(Sheet2!$A$2:$A$7512,MATCH(Sheet3!H2,Sheet2!$A$2:$A$7512,0)))),2)="FA"),INDIRECT("Sheet2!A2:A"&ROW(INDEX(Sheet2!$A$2:$A$7512,MATCH(Sheet3!H2,Sheet2!$A$2:$A$7512,0)))))
Anybody might know whis this happens? Basically I just want to be able to fit everything in 1 formula instead of using 2 columns to get 1 value.
THANK YOU!!!
enter image description here

Related

Problem with IF AND and Vlookup nested formula

I am trying to put a nested IF, AND and Vlookup formula. I want formula to return the value "0.17" in cell F3 if cell D3 has text "pasha" and B3 is not equal to cells mentioned in vlookup formula but its returns zero instead of showing 0.1. Please guide, TIA
=IFERROR(IF(AND(D3="Pasha",VLOOKUP(B3,G70:H78,2,0)<>B3),0.17,IF(VLOOKUP(B3,$B$69:$B$89,1,0)=B3,0.15,"")),0)
enter image description here
You may want to replace
VLOOKUP(B3,G70:H78,2,0)<>B3)
(Excel will unsuccessfully try to match B3 value with values from G column range while it contains different type of data:“Pasha”)
with
NOT(ISNUMBER(MATCH(B3,H70:H78,0)))
And feel free to adjust the second VLOOKUP accordingly.
So, how about this:
You need to to sort the vlookup() but the process for testing the conditions is there.

Get list of rows with a second non-blank value and the column header for the second non-blank occurrence

I have an Excel sheet with data represented as below:
I need to get all the sites with a second non-blank column in the site's row (except Site, of course) and also get the Column Header value.
In the example, sites B, F and G have a second Y. So the result should be:
I am not very well versed with Excel Formulas, but I have experimented a bit with INDEX and I can find the second non-blank value itself. But I can't figure out a way to return the result I require.
Using the below formula I get as far as this, but still nowhere near my expected result.
{=INDEX(B2:I2,SMALL(IF(B2:I2<>"",COLUMN(B2:I2)-COLUMN(B2)+1),2))}
Edit:
With #Harun24HR 's answer I get this new result.
Try below formula.
=INDEX($B$1:$I$1,,SMALL(IF(($B$2:$I$11="Y")*($A$2:$A$11=C14)>0,COLUMN($B$2:$I$11),""),2)-1)
May need array entry with CTRL+SHIFT+ENTER.
Edit#: As per my below screenshot I have used below formulas.
For result column in J2 cell put
=IF(COUNTIF(B2:I2,"<>")>1,ROW(),"")
In C14 put
=IFERROR(INDEX($A$1:$A$11,SMALL($J$1:$J$11,ROW(1:1))),"")
And in D14 cell put below formula.
=INDEX($A$1:$I$1,MAX(($B$2:$I$11<>"")*($A$2:$A$11=C14)*(COLUMN($B$2:$I$11))))
Please note. You no need to array entry for these formulas.
Finally I ended up solving this using a combination of the accepted answer (by #Harun24HR) and How To Extract A Dynamic List From A Data Range Based On A Criteria Without Filters In Excel
In J2 through J11, I added the formula:
{=IFERROR(INDEX($B$1:$I$1,,SMALL(IF(($B$2:$I$11<>"")*($A$2:$A$11=A2)>0,COLUMN($B$2:$I$11),""),2)-1), "")}
In A15 to A24 (same number of rows as the original range), I added the formula:
{=IFERROR(INDEX($A$2:$A$11,SMALL(IF($J$2:$J$11<>"",ROW($A$2:$A$11)),ROW(1:1))-1,1),"")}
In B15 to B24, it's a simple VLOOKUP:
=IFERROR(VLOOKUP(A15,$A$2:$J$11,10,0),"")
This way, the result table is dynamic.

If target cell time (formatted as hh:mm:ss) is within a range, active cell displays text

Active cell is B2. Reference cell is A2, formatted as hh:mm:ss
B2 will display specific text depending on what time is manually inputted in A2. Specifically:
If manually inputted text in B2 is between 12:07:00 - 12:06:00, A1 will display text "Z1".
If manually inputted text in B2 is between 12:05:59 - 12:05:30, A1 will display text "Z2".
If manually inputted text in B2 is between 12:05:29 - 12:05:00, A1 will display text "Z3". etc.
Preference is for an IF function, and not a VLOOKUP. Have tried with a VLOOKUP but I'm obviously doing something wrong:
Undesired result 1 for VLOOKUP attempt:
Undesired result 2 for VLOOKUP attempt:
Thank you!
As a start, I can give you following example, which returns "AAA" in case the time is larger than 12h05.00, and "BBB" in other case:
=IF(B1>=TIME(12;5;0);"AAA";"BBB")
Obviously, you'll need to be able to combine conditions, like:
=AND(B1>=TIME(12;5;0);B1<=TIME(12;6;0))
(which you'll need to embed in your formula)
From here, you have a good start.
In case you still have issues, you can comment this answer.
I know you wanted an if statement however I fixed your vlookup problem for this. You would list the times in ascending order and use the formula =vlookup(a2,$E:$F,2,True). Your column d values are not useful here. This will look up the closest match for A2 that doesn't pass the amount in E.
example

how to evalute the value in excel, need help in formula

I need to populate the value in Column D.
I'm not getting the result using the formula. In the second row, instead of Arun I am getting kumar.
the formula i am using is =IFERROR(INDEX($A$2:$A$10000,MATCH(B2,$C$2:$C$10000,0)),A2)
So works as expected, this entered in cell D2
=INDEX(A$2:A$5,MATCH(B2,$C$2:$C$5,0))
The two errors are due to the blanks in B2 and B4. You can expand it as necessary.
Edit, added the iferror which puts Name? if there is an error:
IFERROR(INDEX(A$2:A$5,MATCH(B2,$C$2:$C$5,0)),"Name?")

Alternative to vlookup with index and match in excel

Cell A1: 0553400710
Cell A2: John
Cell B1: ['0553400710', '0553439406']
Note:
Cell B1 has a fixed format of ['number','number,'number',...... ]
A1 and A2 are user input values
I want to match 0553400710 in Cell A1 with ['0553400710', '0553439406'] in Cell B1.
If it matches, I want to return A2: John.
Is it possible?
I have asked the question before here. it has all the pictures attached as well. Unfortunately no one except one could solve it.
The one who gave me a nearest answer was Jeeped whose answer is
=IFERROR(INDEX(A:A, MATCH("*"&A1&"*",B:B, 0)+1), "")
The problem with this is that it takes the column array instead of rows array. I need it to be in rows as its the best practice for a database. Is there anyone who can improve this solution?
I have also tried vlookup as below but it failed
Here is the data for reference
and here is the input i am trying to match
Is it possible?
=IF(ISNUMBER(SEARCH(A1,B1)),A2,"number not found")
This will work for your example at the top. If A1 looks like ['0553400710'] you could try using SUBSTITUTE formula to remove punctuation.
Not sure what you were trying to do in the bottom bit, sorry.

Resources