=IF(COUNT(B1:B12),LOOKUP(1E100,B1:B12),"")
Ok, the first thing we're doing is testing the range to make sure there is
at least one number entered.
=IF(COUNT(B1:B12)
COUNT returns the count (oddly enough!) of numbers in the range. If COUNT
returns any number other than 0 then the logical test of the IF function
evaluates as TRUE and proceeds to evaluate this portion:
LOOKUP(1E100,B1:B12). If there were no numbers in the range then this
portion would return an error: LOOKUP(1E100,B1:B12). So we use COUNT as an
error trap to prevent that from happening. If there are no numbers in the
range then COUNT returns a 0 and the logical test of the IF function
evaluates to FALSE then proceeds to evaluate this portion: "". This is an
empty TEXT string which leaves the cell looking blank. This is usually more
desireable than seeing errors.
OK, let's assume there are numbers entered in the range. You want to find
the last number entered. This portion of the formula does that:
LOOKUP(1E100,B1:B12).
How it does that (this is kind of confusing at first and may need to be read
a couple of times!):
If the lookup_value is greater than every value in the range the formula
returns the *last* value in the range that is less than the lookup_value. To
ensure that every value in the range is less than the lookup_value so we can
get the last value in the range we use an arbitrary lookup_value that is
guaranteed to be greater than any value in the range.
The arbitrary lookup_value I used is 1E100 which is scientific notation for
a very large number. 1E100 = 1 followed by 100 zeros. That is one huge
number and there's a pretty good chance that 1E100 is greater than every
value in the range. Since 1E100 is greater than every value in the range
LOOKUP(1E100,B1:B12) returns the *last* numeric value entered in the range.
exp101