Right to left offset formula with match - excel

I'm looking to return the start and end dates of a person availability based upon a gantt chart of their hours on a project.
I can at the minute only return the start of their availability, essentially my formula is looking left to right and returning the date of the first "0" cell it meets.
I need the formula to look right to left and return the date of the cell of the last "0" it meets.
Formula currently is:
=IFERROR(OFFSET(B3,(ROW(B3)-2)*-1,MATCH(0,C3:O3,0)),"")

This formula will return the results you're after:
{=INDEX($C$2:$S4,1,MAX(IF($C4:$S4>0,COLUMN($C4:$S4),0)))}
Enter as an array/CSE formula (use Ctrl+Shift+Enter to complete the formula - this will put the curly brackets in).
NB: It will return 00/01/1900 if the last date is greater than 0.
Adding this custom format to the result cells will hide the 00/01/1900: dd/mm/yyyy;;;
I used this to reference to get the answer:
http://www.mrexcel.com/forum/excel-questions/234469-find-last-value-row-greater-than-zero.html

I found the answer by using the formula above and the link provided. My data set was different to the sample one shown. Hence the cell references are different.
=(OFFSET(A3,(ROW(A3)-2)*-1,LOOKUP(9.999999999999E+307,IF(AA3:CP3>0,COLUMN(AA3:CP3)))))

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))

INDEX/MATCH Returning the wrong value. What did I do wrong?

I'm trying to create an spreadsheet where INDEX/MATCH automatically populates monthly sales goals. However, it is returning the wrong number.
In cell B6 I want the value to be 10000. In columns G and H, I've set the goals and the corresponding date in the hopes of matching the goal to the date in row 2.
B6 is returning "6000" AND "7/19/2015" in an adjacent cell when it should just be returning "10000" ... and I don't know why.
In H6 the goal for the 7/12/2015 is set at 10,000 from cell G6, which corresponds to the date in B2, so I don't know why it is returning the date AFTER the one I'm matching.
Thanks
The second part of the formula, the match part, needs to have "H3:H9", not G. The match is looking for your B2 (a date) in the range $G$3:$G$9, which is numbers so there won't be a return of the date.
Edit: And #Jeeped makes a good point, since the dates are going to be found in your table, you would probably be better using "0" instead of "1" at the end - "0" will look for an exact match. If you keep 1, it might return a false positive (return a date that is NEAR your lookup date, not the exact one).
Place in B6 and copy across:
=INDEX($G3:$G9,MATCH(B2,$H3:$H9,1))

Countifs dynamic date criteria

In a =COUNTIFS formula which I'm using, I am looking for data (specifically the number of granted patents) before and after a date. This date is listed in separate column and the last criteria in my COUNTIFS formula refers to this cell. However if I slide this formula downwards or sideways for my sample, the last criteria is not dynamic and keeps referring to the same cell (in the example: N2). How do I alter formula so that I can drag it downwards and sideways?
The current formula:
=COUNTIFS('1972-06-06 - 1988-01-12'!$E$2:$E$366963,'MA Acquiror Permno Cusip'!E2,'1972-06-06 - 1988-01-12'!$C$2:$C$366963,"<=N2")
I have tried a variant where the last criteria looks like:
"<=" & N2
yet this returns no hits, the previous formula does return hits but is not dynamic.
Thanks in advance for any help.
Just had this exact same problem and it took me an hour to figure out.
Apparently you need a space between the operator ("<") and the date.
"<= " & N2
^Should work. Notice the space after the equals sign.

using a function inside an excel IF and use its return value

I use excel for my budget. The top row has the dates when I am paid. I wrote a function called Between which determines if the date I am suppose to pay a particular bill will occur within the timeframe specified in Between. If it does, it will fill the cell with the correct value, otherwise blank. The arguments for Between are Between([cell with start date],[number of days in period], [date to test is in the period],[value to fill cell if date in period]). So, say A1 has 9/1/2014. Between(A1,14,7,500) would put 500 in the cell since the 7th is between 9/1 and 9/15. If A1 was 9/20/2014, the cell would be blank since the 7th is not between 9/20 and 10/4.
I would like to check if Between returns a value vs a blank so I could fill empty cells with a 0 so I can sum up numbers in a row. Suppose I had this expression in a cell say B12:
=IF(ISBLANK(Between(A1,14,7,500),0,?) I want the ? to be the value of Between in the IF statement. How can I get the value of Between into the cell if Between does not return blank?
Just repeat it:
=IF(ISBLANK(Between(A1,14,7,500)),0,Between(A1,14,7,500))
The N function converts non-numbers to 0, so you could try:
=N(Between(A1,14,7,500))

How do I make an excel formula skip empty cells

I have a spreadsheet with data in a single row. The data is arranged by year with the earliest date in the right most cell and the latest date in the far left cell.
What I need is a formula that will begin looking at the cells beginning on the right (earlier date) and move to the left toward a later date skipping the empty cells. As soon as it finds data in one of the cells I need it to stop and show the value in that cell.
I have attached a picture as an example, in that picture I need it to begin at the cell for 2003 and begin moving left ignoring empty cells until it finds a cell with data. In this case the cell for 2005 contains data. I need it to copy that value ($2.43) and place it in the cell marked earliest value.
In the pictue I manually entered 2.43 in the cell for 2005 to show what i need.!
You can use LOOKUP function to get the last value in a row, so if you have years in A1:J1 and dollar amounts in A2:J2 just use this formula to get the last numeric value from A2:J2
=LOOKUP(9.99E+307,A2:J2)
9.99E+307 is [almost] the largest value that Excel allows, when you use that "big num" as lookup value the result is the last number in the range
I made two ranges, starting E4 to J4, I place 1,2,3,4,5,6. Below (thus range: E5-J5) I placed 6,5,4,3,2,1.
In a random cell I placed this formula:
=INDEX(E5:J5,MATCH(MIN(E4:J4),E4:J4,0))
This look in E4:J4 for the number that matched MIN(E4:J4), thus the lowest number. Then selects that value, matching the index, in the range E5:J5.
As follows from your image - year should be less than 10 yr history. In that case try following formula (I suppose that your data ( years and values) are in B3:X4 range):
=HLOOKUP(MIN(IF((B4:X4<>"")*(B3:X3>YEAR(NOW())-10),B3:X3)),B3:X4,2,0)
Note, that it is an array formula, so you need to press CTRL+SHIFT+ENTER to evaluate it.
If you don't need to use condition year should be less than 10 yr history, just remove *(B3:X3>YEAR(NOW())-10) from the formula:
=HLOOKUP(MIN(IF(B4:X4<>"",B3:X3)),B3:X4,2,0)
and press CTRL+SHIFT+ENTER to evaluate it.

Resources