Imagine I have a row of data in excel, like this:
[A] [B] [C] [D] [E] [F] [G] [H]
[1] Data 5 8 12 32 15 9 89
I want a formula that will return the value 9
.
Then, if I add a new value to I1
, it should update to return the value 89
, which would be the new penultimate value.
Ideally this should work on arbitrary ranges, not just entire rows.
Optional bonus points if the method can return an arbitrary offset from the end of the row (say to return the 5th from last item).
Answer
This works with both text and numbers and also doesn't care if there are blank cells, i.e., it will return the 2nd to last non-blank cell. It needs to be array-entered, meaning that you press ctrl-shft-enter after you type or paste it in. Adjust the last argument to change the offset:
=INDEX(1:1,LARGE((1:1<>"")*(COLUMN(1:1)),2))
Comments
Post a Comment