non-blank entry in a range?

H

Harvey Waxman

Is there an easy way to reference the last non-blank entry in a range without
using some sort of macro?

Thanks
 
J

JE McGimpsey

Harvey Waxman said:
Is there an easy way to reference the last non-blank entry in a range without
using some sort of macro?

One way:

=LOOKUP(2,1/(A1:A65535<>""),A1:A65535)
 
H

Harvey Waxman

JE McGimpsey said:
One way:

=LOOKUP(2,1/(A1:A65535<>""),A1:A65535)

Excellent. Can you "englishify" it? I checked the help in Excel but it isn't
enough for these gray cells.

Thanks
 
J

JE McGimpsey

Excellent. Can you "englishify" it? I checked the help in Excel but it
isn't
enough for these gray cells.

By "englishify" it, I assume you mean explain what the parts do:

1) (A1:A65535<>"") creates an array of FALSE/TRUE depending on whether
the cells are blank or not, respectively.

2) 1/{TRUE,TRUE,FALSE,TRUE,...} coerces the array to 1/0 (for
TRUE/FALSE) and divides 1 by the coerced array to produce

{1,1,#DIV/0,1...}

3) LOOKUP(2,{1,1,#DIV/0,1...},A1:A65535) looks through the array for the
value 2, which obviously doesn't exist, so it finds the last value *less
than or equal to* 2 (i.e., the last 1), and returns the value in
A1:A65535 corresponding to the index of that last 1.
 
H

Harvey Waxman

JE McGimpsey said:
By "englishify" it, I assume you mean explain what the parts do:

1) (A1:A65535<>"") creates an array of FALSE/TRUE depending on whether
the cells are blank or not, respectively.

2) 1/{TRUE,TRUE,FALSE,TRUE,...} coerces the array to 1/0 (for
TRUE/FALSE) and divides 1 by the coerced array to produce

{1,1,#DIV/0,1...}

3) LOOKUP(2,{1,1,#DIV/0,1...},A1:A65535) looks through the array for the
value 2, which obviously doesn't exist, so it finds the last value *less
than or equal to* 2 (i.e., the last 1), and returns the value in
A1:A65535 corresponding to the index of that last 1.

Thanks again.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top