**Please Note: **
This article is written for users of the following Microsoft Excel versions: 2007 and 2010. If you are using an earlier version (Excel 2003 or earlier), *this tip may not work for you*. For a version of this tip written specifically for earlier versions of Excel, click here: Referencing the Last Cell in a Column.

Patty asked about a common scenario, in which column B contains quite a bit of data, and information can be added to the cells in the column at any time. In a formula in cell C4, Patty wants to see the value at the bottom of those cells in column B that contain values. Thus, if cells B1:B27 contain data, then in cell C4 Patty wants to see the value that is in cell B27. If three more pieces of data are added to column B, then the value in C4 should contain the value in B30.

The solution to this problem depends on whether you can count on the data in column B containing blank cells or not. If the data is contiguous—it doesn't contain any blank cells—then you can use the following formula in C4:

=INDIRECT("B"&COUNTA(B:B))

This constructs an address based on the last cell in the column, and then uses the INDIRECT function to return the value at that address.

If it is possible for there to be blanks in column B, then the following formula will work:

=INDIRECT("B"&MAX(ROW(1:1048576)*(B1:1048576<>"")))

Again, the INDIRECT function is used to fetch the actual value, but the address used by INDIRECT is put together differently.

A different approach is to use the VLOOKUP function to return the value. If column B consists of numeric values, then the following formula in C4 will work just fine:

=VLOOKUP(9.99999999999999E+307,B:B,1)

If column B contains text, then the numeric lookup won't work, but the following will:

=VLOOKUP(REPT("z",50),B:B,1)

*ExcelTips* is your source for cost-effective Microsoft Excel training.
This tip (11030) applies to Microsoft Excel 2007 and 2010. You can find a version of this tip for the older menu interface of Excel here: **Referencing the Last Cell in a Column**.

**Save Time and Supercharge Excel!** Automate virtually any routine task and save yourself hours, days, maybe even weeks. Then, learn how to make Excel do things you thought were simply impossible! Mastering advanced Excel macros has never been easier. Check out *Excel 2010 VBA and Macros* today!

Excel includes a handy shortcut for entering data that is similar to whatever you entered in the cell above your entry ...

Discover MoreCopying from one cell to another is easy when editing your worksheet. Doing the copying without selecting a cell other ...

Discover MoreUsing the mouse to select a large cell range can be frustratingly slow. If you want to make copying to a large range of ...

Discover More**FREE SERVICE:** Get tips like this every week in *ExcelTips,* a free productivity newsletter. Enter your address and click "Subscribe."

2015-12-30 06:05:12

Barry

2015-07-21 09:47:29

Parker

2015-04-16 11:40:54

Chuck Trese

There are many methods, each has it's pros and cons. Here is a fairly foolproof method, based on your question.

Range("A"& cells.Rows.Count).End(xlUp)

This method starts in column A, goes all the way to the bottom, then does the equivalent of Ctrl-UpArrow to find the last non-empty cell. The up-side to this one is that it looks for anything other than an empty cell. The down-side to this one is that if you have a formula in the cell that returns "", it can still give you that 'empty' cell, because this method does not consider a formula as empty.

2015-04-16 11:38:14

Michael

I have an existing formula:

=VLOOKUP(B143,'Daily >0 5-minute'!E$12252:G$18791,2,FALSE)

in which I would like to replace "18791" with the row of the current last cell. I can find that value easily with

=COUNTA('Daily >0 5-minute'!A:A)

but all my attempts to embed that formula in the VLOOKUP argument have resulted in a variety of errors.

2015-04-15 13:52:13

Scott Levy

2015-02-01 08:34:10

JMJ

Yep, it DOES help!

Thanks!

2015-01-31 13:30:57

Willy Vanhaelen

My version is 2007. I had the same problem with some array formulas in former versions. Try to restrict your range as for instance:

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

Perhaps that helps.

2015-01-31 08:24:03

JMJ

Yes tour formula is very nice and concise, but... Before writing my formula, I did tried yours, but I did not succeed in getting it to work: it gives a #NUMBER error, seemingly from the A:A<>"" part(?)

Maybe we have different XL versions? Mine is 2003 SP3...

2015-01-30 13:39:45

Willy Vanhaelen

Why use so a lenghty formula when this very short one does the same job?

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

2015-01-30 11:52:57

JMJ

=IF(ISNA(MATCH(9^15,B:B)),INDIRECT("B"&MATCH("*",B:B,-1)),IF(ISNA(MATCH("*",B:B,-1)),INDIRECT("B"&MATCH(9^15,B:B)), INDIRECT("B"&MAX(MATCH(9^15,B:B),MATCH("*",B:B,-1)))))

A bit lengthy, but thoroughly tested.

Hope this helps.

2015-01-28 07:28:15

Willy Vanhaelen

Better even use A:A<>"" when you want a 0 value or a formula returning 0 to be included.

2015-01-27 14:27:04

Michael (Micky) Avidan

You will be better off with the use of: A:A<>0 especially in cases of a negative value.

Michael (Micky) Avidan

“Microsoft® Answers" - Wiki author & Forums Moderator

“Microsoft®” MVP – Excel (2009-2015)

ISRAEL

2015-01-27 12:26:57

Alfred Polan

2015-01-27 09:55:47

Chuck Trese

Building off your idea, here's a generic form (won't break if you move your table).

=INDEX(Table2,ROWS(Table2))

2015-01-27 04:45:25

David Sheen

2015-01-26 09:30:28

Chuck Trese

Here's an array formula that works for any named range (assuming range is one column wide, of course). If you name your range MyRange, then the below array formula works:

=INDIRECT("R"&MAX(ROW(MyRange)*(MyRange<>""))&"C"&COLUMN(MyRange),FALSE)

Enter using Ctrl-Shift-Enter.

2015-01-26 09:07:53

Chuck Trese

Here is an improvement on the formula given in the tip (finding last item in all of column B):

=INDIRECT("B"&MAX(ROW(B:B)*(B:B<>"")))

Again, this is an array formula, so you must enter it by pressing Control-Shift-Enter.

2015-01-26 08:56:28

Chuck Trese

=INDIRECT("B"&MAX(ROW(1:1048576)*(B1:B1048576<>"")))

only works as an array formula. This means you do not enter it by pressing Enter, you have to press Control-Shift-Enter (sometimes called CSE). When you do this correctly, Excel will put curly braces around the formula and it will give correct results.

Patrick, your formula is correct, but same problem. Enter using Control-Shift-Enter, all at the same time.

2014-11-21 13:06:44

Patrick

I used the following formula to find the last value in column G between rows 170 to 190 with some blank cells...

=INDIRECT("G"&MAX(ROW(170:190)*(G170:G190<>"")))

and I get the #VALUE! error message.

Thank you,

Patrick

2014-11-17 15:35:46

Hank

=INDIRECT("B"&MAX(ROW(1:1048576)*(B1:1048576<>"")))

does not function for Excel 2010.

Would appreciate correction.

2014-10-04 11:49:02

Pete

=AVERAGE(INDIRECT("k"&D1&":k"&D2))

to get the average even when new data is added.

However this seems not to work in Graph data ranges! If I try to keep my charts updated in the same way, I get a Formula error every time. Do chart ranges work differently?

Thanks,

Pete

2014-10-01 17:16:39

The ADDRESS function returns a text-string of the address. In order for it to be used to return the value at that address it needs to be put inside the INDIRECT() function.

=INDIRECT(ADDRESS(row_num,col_num)

It's a beautiful thing! No more hard-coded Column letters.

I take it one more step. I name my columns, use the COLUMN() function and the ROW() function.

=INDIRECT(ADDRESS(ROW(),COLUMN(<column name>))

While I'm all excited about this, that COLUMN() function with NAMES is handy in VLOOKUP()'s for bullet proofing the value (first argument) and offset (third argument). It makes for long formulas but if someone inserts a column or deletes one there is no problem.

Let's say you've Named the following

- Column where Argument 1 values are: PartNumberCol

- Table where you are looking up the information (Argument 2): PartsLocationTable

- Column in PartsLocationTable where the information is that you need: PartsBinCol

Argument 1: INDIRECT(ADDRESS(ROW(),COLUMN(PartNumberCol))

Argument 2: PartsLocationTable

Argument 3: COLUMN(PartsBinCol) - COLUMN(PartsLocationTable) + 1

2014-09-29 16:36:50

Pete

I have data that I update daily by adding new rows. I want to use the new row number in other calculations

eg =COUNTIFS(L6:L56,"Won",J6:J56,">0")

If I add 3 rows of data L59 and J59 will become the new addresses in the formula above.

I tried it using

=COUNTA(A:A)+5 (in cell D2)

to get the number of used rows (adding a constant, known offset) and then use this in

=ADDRESS(D2,12)( in cell F2)

.. but this

=COUNTIFS(L6:F2,"Won",J6:J56,">0")

does not work, nor does

=COUNTIFS(L6:ADDRESS(D2,12),"Won",J6:J56,">0")

How can I get a formula to use the address reference I found with the ADDRESS function?

Thanks,

Pete

2014-07-30 06:50:27

Haley

Even when fixed this formula is returning the first value in column B, not the last, and results in a #REF! error when the first cell in the range is blank.

2013-12-31 06:18:06

Michael (Micky) Avidan

Try to learn all about the 'OFFSET' function.

In order to help you - please upload your workbook to one of many File Hosting sites and present the link to the file.

Please explain - in details - the requested results as per your file.

Michael (Micky) Avidan

“Microsoft® Answers" - Wiki author & Forums Moderator

“Microsoft®” MVP – Excel (2009-2014)

ISRAEL

2013-12-30 18:31:58

Courage

But, I would like to look up the bottom 5 to 10 entries, so the first 5-10 empty cells in column H?

Could you help with this? Or is it possible with a formula?

Got a version of Excel that uses the
ribbon interface (Excel 2007 or later)?
**This site is for you!** If you
use an earlier version of Excel, visit
our *ExcelTips* site focusing on the menu interface.

**FREE SERVICE:** Get tips like this every week in *ExcelTips,* a free productivity newsletter. Enter your address and click "Subscribe."

Copyright © 2019 Sharon Parq Associates, Inc.

## Comments