I have the formula to find the last value in a row - =LOOKUP(1,1/(3:3>0),3:3) (depending on the row)
but can't seem to get it to return the second to last value/cell in the row.
Please help!
Try,
=INDEX(3:3, AGGREGATE(14, 6, COLUMN(A:XFC)/(A3:XFC3>0), 2))
Awesome.. I edited the formula to:
=INDEX(3:3, AGGREGATE(14, 6, COLUMN(A3:XFC3)/(A3:BL3>0), 2))
Where BL3 is where my current last data value ends. Once I drag, the formula automatically updated the column and row value.
Thanks so much!
For row #3, the array formula:
=INDEX(3:3,IF(COUNTA(3:3)=0,"",MAX((3:3<>"")*(COLUMN(3:3))))-1)
will yield the next-to-last value in that row:
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.
If you are sure that row #3 will not be empty, then use this array formula instead:
=INDEX(3:3,MAX((3:3<>"")*(COLUMN(3:3)))-1)
To avoid array formulas consider:
=INDEX(3:3,SUMPRODUCT(MAX((COLUMN(3:3))*(3:3<>"")))-1)
Related
Here is the excel function:
start date =IF(A6 = 1, C3, VLOOKUP(A6 -1, $A$6:$D$13, 4, FALSE))
end date =C6+B6
I intend to get the latest end date value if there is multiple rows on previous sequences, for example as below:
On the yellow cell, it should get the 23/2/2019 instead of 18/2/2019.
Use LOOKUP:
=IF(A12=1,C9,LOOKUP(A12-1,$A$6:$A$13,$D$6:$D$13))
Edit:
to get latest date you can use AGGREGATE function:
=IF(A6 = 1; C3; AGGREGATE(14;4;($A$6:$A$13=A6 -1)*$D$6:$D$13;1))
I think this will serve your purpose. This is formula for first start-date value and drag it downwards.
=IF(A6=1,$C$3,MAX(IF(A6-1=$A$6:$A$14,VLOOKUP(A6-1,$A$6:$D$14,3)+$B$6:$B$14)))
NOTE this is array formula so enter it with ctrl + shift + enter and check for curly braces around the formula. The screenshot to check for all conditions
Check for seq 6, I added two values sorted differently now
If number from first coulmn is found in the second column, it should return that number.
If number from first coulmn is not found in the secound column, it should return closest possible min value
You can use vlookup() like this, BUT you need to sort the values:
In C1 enter the array formula:
=MAX(IF(B:B<=A1,B:B))
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.
NOTE:
Sorting is not required.
Array entry is not required if you are using Excel 365.
Another option is SUMPRODUCT:
=SUMPRODUCT(MAX(--($B$1:$B$12<=A1)*$B$1:$B$12))
It works on Excel 2007 or higher, no need of array entered formula and no need of sorting.
I am trying to do vlookup, but however it is matching only first row and my return value is always at last Column (reason).
=vlookup(H:H,A:F,6,0)
I tried with Match and Index functions, but it's not looking up for values other than first column.
I know the vlookup will not work, but any suggestions?
Try INDEX/AGGREGATE combination:
=INDEX($F$2:$F$6,AGGREGATE(15,6,(1/(H2=$A$2:$E$6))*ROW($F$2:$F$6)-1,1))
Try this shorter formula.
In I2 enter array formula and copied down :
=INDEX(F:F,SUM((IFNA($A$2:$E$6,"")=H2)*ROW($A$2:$E$6)))
This is an array formula and needs to be confirmed by pressing with Ctl + Shift + Enter.
I have an excel index/match formula (see below) but my data contains duplicate values therefore excel only returns the first value. Is there a way to modify my formula below to return to the nth value?
=IF(B24>='3. Lookups'!CU:CU, INDEX('3. Lookups'!CZ:CZ, MATCH(AC24, '3. Lookups'!CT:CT,0)), "blank")
Try something like this for the INDEX part. This will return the second value. For the Nth value, adjust the last parameter in the formula.
=INDEX('3. Lookups'!CZ:CZ,SMALL(IF('3. Lookups'!CT:CT=AC24,ROW('3. Lookups'!CT:CT)-ROW(INDEX('3. Lookups'!CT:CT,1,1))+1),2))
It's an array-formula, so use Ctrl + Shift + Enter to confirm,
Try,
=iferror(index('3. Lookups'!CZ:CZ, aggregate(15, 7, row(a:a)/('3. Lookups'!CT$1:CT$9999=AC24), nth)), "blank")
Replace nth with the actual number you want returned.
I am trying to find the location (row number) of the first blank cell in a column of data. Previous questions (such as this one) have helped, but by data contains header rows (7 in this case), which may be blank. Therefore, I am only interested in blank cells from row 8.
My attempts so far have tried the formula below, but thought it seems to create the lookup_array I want, it doesn't work with match_type set to -1. Don't understand why.
=MATCH(8, IF(ISBLANK(A:A), ROW(A:A), 0),-1)
This just gives #N/A for some reason. The IF statement appears to return the correct data, e.g. {0,0,3,0,5,0,0,0,9,0,0,0,13,0,...} for blanks in rows 3, 5, 9 & 13, but expect the MATCH to return 9, as the smallest match greater than 8.
PS - It's important that only the row is referenced, as I don't know how long the data block will be and the formula should work with any length data.
As pnuts commented in the answer you linked, you can use the following formula:
=MATCH(TRUE,INDEX(ISBLANK(A2:A1048576),0,0),0)
in your case just change the 2 to the first row you want to count from:
=MATCH(TRUE,INDEX(ISBLANK(A8:A1048576),0,0),0)
This will give you the first position of the empty blank, starting from the 8th Row. If it is in A9, this will return "2".
The alternative you had in your comment:
=MATCH(TRUE,IF(ISBLANK(A:A), ROW(A:A), 0)>7,0)
also works but MUST be entered as an array formula by pressing the combination ctrl + shift + enter when entering the formula:
{=MATCH(TRUE,IF(ISBLANK(A:A), ROW(A:A), 0)>7,0)}
If the cells are populated by a formula use
=MATCH(TRUE,INDEX(*"RANGE"*=""),0)