
Tips.Net > ExcelTips Home > Editing > Referencing the Last Cell in a Column
Summary: Do you want to reference whatever is stored in the last-used cell in a column? How you go about accessing that information in a formula depends on whether the column contains blank cells or not. This tip discloses the various ways you can access the desired info. (This tip works with Microsoft Excel 97, Excel 2000, Excel 2002, and Excel 2003.)
Subscriber Patty Laferriere 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:65535)*(B1:B65535<>"")))
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)
Tip #2103 applies to Microsoft Excel versions: 97 2000 2002 2003
PivotTables Got You Perplexed? Learn the ins and outs of this powerful data-crunching tool. ExcelTips: PivotTables for the Faint of Heart makes it easy.
Want to make Excel do even more? The way is easy when you know how to use macros. This great e-book makes it easy. (more information...)
Ask an Excel Question
Make a Comment
ExcelTips FAQ
ExcelTips Premium
Beauty Tips
Bugs and Pests Tips
Car Tips
Cleaning Tips
College Tips
Cooking Tips
Excel2007 Tips
ExcelTips
Family Tips
Gardening Tips
Health Tips
Home Tips
Money Tips
Organizing Tips
Pet Tips
Word2007 Tips
WordTips
Advertise on the
ExcelTips Site