View Single Post
  #14   Report Post  
Roger Govier
 
Posts: n/a
Default Find Last Row in Column

Hi Aladin

Thank you for the notes.
This will fail when there is either no text or no numeric data.

I had rather assumed, that if the OP had a totally empty column, then he
wouldn't be looking for the last used row, hence the #N/A return from a
totally blank column didn't really seem to be material.

BTW, the OP is asking for the row number, not the address

Yes, on re-reading the original post, the OP does ask for row and not cell
address. The formula should be amended to

=CELL("Row",INDEX(A:A,MAX(MATCH(99999999,A:A),MATC H("ZZZZ",A:A))))

However, did you consider endless variations the people may come up with,
causing a jungle of constants, hard to explain to new comers?

No, I didn't. But I did give the formula for a large numeric value or large
text value if the user chose to use those instead.

Neither did I go on to explain that in reality, I use defined names for
large numbers and large text values, which I use in my formulae rather than
having to count how many 9's I am entering every time I use this type of
Lookup, and enabling the call of the REPT() function to be made once, rather
than throughout every formula.

InsertNameDefine
Name BigN Refers to =9.99999999999999E+307
Name BigT Refers to =REPT("Z",255)
(these were tips I picked up from Bob Phillips)

=CELL("Row",INDEX(A:A,MAX(MATCH(BigN,A:A),MATCH(Bi gT,A:A))))

I think it is sometimes of more value to the OP to get a rapid answer that
answers their immediate need, rather than wait longer for a comprehensive
answer that suits everyone.

But then again, perhaps I am wrong.<g

Regards

Roger Govier


Aladin Akyurek wrote:
Two notes...

This will fail when there is either no text or no numeric data. BTW, the
OP is asking for the row number, not the address of the last
numeric/text value.

You state:
"Some people use the largest number Excel can handle
(9.99999999999999E+307) in the search for numbers, and REPT("Z",255) for
text, but I have usually found the above to meet my needs."

Maybe so. However, did you consider endless variations the people may
come up with, causing a jungle of constants, hard to explain to new comers?


Roger Govier wrote:

Hi

One way
=CELL("Address",INDEX(A:A,MAX(MATCH(99999999,A:A), MATCH("ZZZZ",A:A))))

This will look for the last numeric or last text value in column A and
return the cell reference where found.
Some people use the largest number Excel can handle
(9.99999999999999E+307) in the search for numbers, and REPT("Z",255)
for text, but I have usually found the above to meet my needs.

Regards

Roger Govier


wrote:

Hi TemplateBuilder,

Thank you for your solution but that is not exactly what I am after ...

Imagine you have only 5 values filled in Column A ...bu the 5th is at
row 125 then I would like it to return 125 and not 5 (or 6).

Brgds Sige