Last non-empty cell in a column?

  • Thread starter Thread starter Stuart Dawson
  • Start date Start date
S

Stuart Dawson

This should be an easy one, but I can't seem to find it.

I need a formula to return the last non-empty cell in a column.
Something like "LASTNONBLANK(F:F)" is kind of what I'm after, but I
can't seem to find anything in the Help facility to do it.

Thanks

Stuart Dawson
--
|>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
Stuart Dawson Dawson Engineering
(e-mail address removed) Belfast, Northern Ireland

neXus construction layout software for Texas Instruments calculators
http://www.dawson-eng.demon.co.uk/nexus/
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<|
 
the array formula
=MAX((NOT(ISBLANK(F1:F65535))*(ROW(F1:F65535))))+1

will work

note: Has to be entered as an array formula ctrl-shift-
enter

Lance
-----Original Message-----

This should be an easy one, but I can't seem to find it.

I need a formula to return the last non-empty cell in a column.
Something like "LASTNONBLANK(F:F)" is kind of what I'm after, but I
can't seem to find anything in the Help facility to do it.

Thanks

Stuart Dawson
[/QUOTE]
Stuart Dawson Dawson Engineering
(e-mail address removed) Belfast, Northern Ireland

neXus construction layout software for Texas Instruments calculators
http://www.dawson-eng.demon.co.uk/nexus/
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
<<<<<<<<<<|
.
[/QUOTE]
 
An alternative to Aladin's solution, just for variation, and it works for
numbers or text

=INDIRECT("F"&MAX(IF(NOT(ISBLANK(F1:F65535)),ROW(1:65535))))

This is an array formula, and so is entered with Ctrl-Shift-Enter.
 
Note that the array formulas suggest will be much slower to recalculate than
Aladin's formula.
 
Aladin Akyurek said:
If F is numeric,

=LOOKUP(9.99999999999999E+307,F:F)

will fetch the last value in F.

=MATCH(9.99999999999999E+307,F:F)

will return the position of the last value in F.

If F is of 'text' type, replace the big number in the above formulas with
REPT("z",255).


Thanks, Aladin. Exactly what I was after.

Lance, Bob, Tom - thanks for your input.

Best regards

--
|>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
Stuart Dawson Dawson Engineering
(e-mail address removed) Belfast, Northern Ireland

neXus construction layout software for Texas Instruments calculators
http://www.dawson-eng.demon.co.uk/nexus/
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<|
 
absolutely they will notice. Doing an array formula is considerably slower.
It doesn't take too many array formula in my workbooks before I have to turn
off automatic calculation. I wouldn't expect that to be the case with
Aladin's formula. I didn't bring it up because I thought it was trivial.

I put your formula in 55 cells in row 1 and do a full recalc and it takes
about 5 seconds to calculate. I put in Aladins in the same cells and do a
full recalc and it is much less than a second - almost instantaneous. I put
it in many cells so I can visually see the difference - but the bottom line
is it is much slower. If it will only appear in one cell, then maybe it
isn't a big issue, but that usually isn't the case.

Regards,
Tom Ogilvy
 
Whats your CPU processor speed?

Tom said:
absolutely they will notice. Doing an array formula is considerably slower.
It doesn't take too many array formula in my workbooks before I have to turn
off automatic calculation. I wouldn't expect that to be the case with
Aladin's formula. I didn't bring it up because I thought it was trivial.

I put your formula in 55 cells in row 1 and do a full recalc and it takes
about 5 seconds to calculate. I put in Aladins in the same cells and do a
full recalc and it is much less than a second - almost instantaneous. I put
it in many cells so I can visually see the difference - but the bottom line
is it is much slower. If it will only appear in one cell, then maybe it
isn't a big issue, but that usually isn't the case.

Regards,
Tom Ogilvy
 
What difference does it make - both were tested on the same machine and the
important thing is the relationship between them. The timing was done by
looking at my watch - not using the computer - but the difference is so
gross, it really isn't contestable.

Your certainly free to use any formula you choose, however. It just is
misleading to propose a less efficient solution when an excellent solution
was offered. Since two people offered the less efficient solution, it might
be confusing to the OP - I just wanted to clarify the real situation.

I am not bashing array formulas - I use them all the time and there are
situations where they are certainly necessary - Aladin has shown this isn't
one of them.

1.8 Mhz AMD Athlon

from sysinfo in Excel help

AuthenticAMD AMD Athlon(tm) XP 2200+
224MB RAM


Regards,
Tom Ogilvy
 
Tom Ogilvy said:
What difference does it make - both were tested on the same machine and the
important thing is the relationship between them. The timing was done by
looking at my watch - not using the computer - but the difference is so
gross, it really isn't contestable.

It isn't gross on my machine even with 55 array formulae. I would suggest
that this level of array formulae is not typical, so my original assertion
that it won't be noticed in the majority of cases holds (IMO).
It just is misleading to propose a less efficient solution when an excellent solution
was offered.

Now hold. I stated clearly in my post that I was offering an alternative,
for variation, and also one that works for both numbers and text, which
Aladin's does not. Posting an alternative solution is perfectly legitimate,
one that you yourself do more times than most, and your comment about it
being less efficient was also legitimate ... as a warning for complex
spreadsheets. But that statement above ... not appropriate.The majority of
spreadsheets that come across my desk have no array formulae in them, let
alone 55.

Bob
 
Tom,

Of course it is relevant whether you can observe the difference or not. A
task that takes 1ms or one that takes 5ms, in most circumstances who cares?
And that was the point of my original response,... in most cases.

Nobody is arguing about pointing other aspects out, as I said in my reply,
but for you to suggest that we were being misleading, especially considering
the statements that I added to my post is scurrilous.

I note that there have been thousands of previous post that have offered
array formulae after non-array formulae which you didn't decide to jump in
on, now I wonder why that might be?
I create spreadsheets with more than 55 array formula on a routine basis. I
suspect we use spreadsheets for much different purposes.

Oh dear, oh dear!
You attempted to belittle the assertion: "Like anyone will notice in 99.99%
of the cases." and appeared to take it as some type of personal
disparagement.

Accepted that, although it was not meant that way, it could be taken as
such. My error and apology. But if that was your original beef, why not just
say so, rather than accuse me of misleading anyone? Not very grown-up.
This whole thread beyond my post is pretty much a waste of time in my
opinion.

I think that that sentence says a lot about you. And yet you go on ( and
on).
If you are just offering for variation why the big to do about
there is no difference -- when there is? You state you don't have much
experience here, so why argue.

I don't think there was a big to-do, just trying to counter a nasty
statement about misleading people.

This is the second time that we have been here. I know that your Excel
knowledge is excellent, and that the help that you give in these NGs is
something special, but you seem to go seeking to criticise. I well accept
that I may be well off-track here, but I get the impression of a pompous,
vindictive nature in yourself.. I fully expect that this will lead to you
seeking me out even to criticise, but I can handle that.


--

HTH

-------

Bob Phillips
... looking out across Poole Harbour to the Purbecks


Tom Ogilvy said:
Whether you can observe the difference or not, and as a rough estimate it is
~ five times slower than the method proposed by Aladin - a fast machine does
not change that and as I stated, I only used 55 to make the difference
timable - even one instance would be ~ five times slower (sheesh). Has
nothing to do with complex spreadsheets - it is slower in each instance -
whether it is something that needs to be considered would be up to the
user - but it wouldn't be considered if they didn't know. And there is
nothing wrong with me telling the OP that the array formula is slower.

I create spreadsheets with more than 55 array formula on a routine basis. I
suspect we use spreadsheets for much different purposes.


"Now hold"

And all I said was:

Note that the array formulas suggest [sic] will be much slower to
recalculate than
Aladin's formula.

I didn't criticize anyone's submission in my post or say that an alternative
solution shouldn't be offered.

You attempted to belittle the assertion: "Like anyone will notice in 99.99%
of the cases." and appeared to take it as some type of personal
disparagement.

This whole thread beyond my post is pretty much a waste of time in my
opinion. If you are just offering for variation why the big to do about
there is no difference -- when there is? You state you don't have much
experience here, so why argue.

Regards,
Tom Ogilvy
 
Give me a break.

I said it is misleading - in that two people suggesting array formulas could
mislead the OP into believing Aladin's was not the way to go - I didn't say
anyone was trying to mislead the OP (sheesh).

You are so bent on taking offense where none has been offered that
apparently you can't see the truth. Take a day and go back and read what
has been written - perhaps you will come to some reasonable conclusion.

As far as criticizing you, I don't believe I ever have. In the only other
instance I recall, you took magnificent offense because I appropriately
corrected something you had posted - again, your reaction was way out of
proportion and the offense was all in your own mind - it was certainly so
long ago and inconsequential to me that I can't recall the details. So yes,
you have established a history of taking offense where none is intended or
was given. The exchange stands on its own as to who is offending and acting
out.

Enjoy your radio.

Regards,
Tom Ogilvy
 
Back
Top