5thQuadrant
New member
- Joined
- Mar 18, 2021
- Messages
- 20
- Reaction score
- 0
- Points
- 0
- Excel Version(s)
- MS 365 for Enterprise
Which is the last non-blank cell in this diagram, B or C, and why?
=INDEX(E2:N11,MAX(IF(ISBLANK(INDEX(E2:N11,0,MAX(IF(ISBLANK(E2:N11),FALSE,COLUMN(E2:N11)-COLUMN(E2)+1)))),FALSE,ROW(E2:N11)-ROW(E2)+1)),MAX(IF(ISBLANK(E2:N11),FALSE,COLUMN(E2:N11)-COLUMN(E2)+1)))
A formula such as:seems to me to be unduly long, but it's what first worked while I experimented. I suspect there'll be something a lot shorter.Code:=INDEX(E2:N11,MAX(IF(ISBLANK(INDEX(E2:N11,0,MAX(IF(ISBLANK(E2:N11),FALSE,COLUMN(E2:N11)-COLUMN(E2)+1)))),FALSE,ROW(E2:N11)-ROW(E2)+1)),MAX(IF(ISBLANK(E2:N11),FALSE,COLUMN(E2:N11)-COLUMN(E2)+1)))
What version of Excel are you using; I can try with some of the more recent worksheet formulae.
As it stands, this formula might need array-entering (means committing the formula to the sheet using Ctrl+Shift+Enter rather than just Enter).
There are 7 references to the whole table range (E2:N11) and 3 references to the top left cell of the table range (E2).
=INDIRECT(ADDRESS(XLOOKUP(TRUE,INDEX(E2:N11,0,MAX((E2:N11<>"")*COLUMN(E2:N11))-COLUMN(E2)+1)<>"",ROW(E2:N11),"",0,-1),MAX((E2:N11<>"")*COLUMN(E2:N11))))
=LastinLastColumn(E2:N11)
Function LastinLastColumn(rng)
Set rr = rng.Find(What:="*", LookAt:=xlPart, LookIn:=xlFormulas, SearchOrder:=xlByColumns, SearchDirection:=xlPrevious, MatchCase:=False, Searchformat:=False)
If Not rr Is Nothing Then LastinLastColumn = rr.Value Else LastinLastColumn = "Empty range"
End Function
A bit shorter (if the formula's on the same sheet):Code:=INDIRECT(ADDRESS(XLOOKUP(TRUE,INDEX(E2:N11,0,MAX((E2:N11<>"")*COLUMN(E2:N11))-COLUMN(E2)+1)<>"",ROW(E2:N11),"",0,-1),MAX((E2:N11<>"")*COLUMN(E2:N11))))