Please Note: This article is written for users of the following Microsoft Excel versions: 97, 2000, 2002, and 2003. If you are using a later version (Excel 2007 or later), this tip may not work for you. For a version of this tip written specifically for later versions of Excel, click here: Retrieving the Last Value in a Column.

# Retrieving the Last Value in a Column

Written by Allen Wyatt (last updated February 25, 2023)
This tip applies to Excel 97, 2000, 2002, and 2003

You may wonder if there is a way to return the last (not largest) value in a column. For instance, if there are values in A1 through A5, then you may want the value in A5 returned. Later, if values were added in A6 through A8, then the value in A8 should be returned.

There are a couple of ways that a solution can be approached. The first is to use a formula such as the following:

```=INDEX(A:A,COUNT(A:A))
```

This formula returns the last numeric value in a column, providing that the values begin at (in this case) A1. This approach only works if all the values in the column are numeric. If the values are non-numeric, or if there are blank cells intermixed with the values, then a different approach is necessary. One way is to copy the following formula into column B, just to the right of the cells that may contain values:

```=IF(ISNUMBER(A2),IF(A2<>0,ROW(A2),""),"")
```

In this case, the formula returns the row number of any cell in A which contains a numeric value greater than zero. The following formula can then be used to retrieve the last value in column A:

```=INDEX(A:A,MAX(B:B))
```

This formula works because it returns the largest row number from column B, and then uses that as an index to return the corresponding value from column A.

If your range of data contains a mixture of numeric and non-numeric values (and, perhaps, even some blank cells intermixed in the range), then you might consider the following formula:

```=LOOKUP(2,1/(1-ISBLANK(A:A)),A:A)
```

The way this formula works may not be evident at first. The ISBLANK portion returns an array that contains a True or False value for each cell in column A, depending on whether that cell is blank or not. That True or False value (which is really a 1 or 0) is subtracted from 1 so that you end up with the True values being 0 and the False values being 1.

The next step is to use the 1 or 0 values as the dividend in 1/x. This effectively "inverts" the value, and you end up with either 1 (1/1) or a #DIV/0! error (1/0). Remember that this is an array that is then used as a parameter to the LOOKUP function. What is being searched for in the array is the value 2, which does not exist there. (Remember that the array contains only the values 1 or an error value.) The LOOKUP function actually ignores all the error values in the array, and so it returns the offset, within the range A:A, of the last array element that contains a 1 value. This corresponds to the last cell in the range that is non-blank.

As you can tell, returning the last value in a column can get a bit tricky at times. A clean approach is to simply develop your own VBA function that returns the desired value. In this case you can program the function to return any value—not just numeric values. A fine example of such a function is available at John Walkenbach's Web site. Check out the following:

```http://spreadsheetpage.com/index.php/tip/determining_the_last_non_empty_cell_in_a_column_or_row/
```

ExcelTips is your source for cost-effective Microsoft Excel training. This tip (2512) applies to Microsoft Excel 97, 2000, 2002, and 2003. You can find a version of this tip for the ribbon interface of Excel (Excel 2007 and later) here: Retrieving the Last Value in a Column.

##### Author Bio

Allen Wyatt

With more than 50 non-fiction books and numerous magazine articles to his credit, Allen Wyatt is an internationally recognized author. He is president of Sharon Parq Associates, a computer and publishing services company. ...

##### MORE FROM ALLEN

Trouble Recording Paste Special Formula

Sometimes, when you upgrade to a new version of Excel, you could run into a problem recording macros that you had no ...

Discover More

Comments Use Tiny Font when Printed

When you print out your documents, do any comments in the document appear very tiny on the printout? It could be because ...

Discover More

Hiding the Taskbar when It is Not in Use

Don't like the Taskbar visible on the screen? You can easily hide it when you aren't using it by making just one small ...

Discover More

Program Successfully in Excel! John Walkenbach's name is synonymous with excellence in deciphering complex technical topics. With this comprehensive guide, "Mr. Spreadsheet" shows how to maximize your Excel experience using professional spreadsheet application development tips from his own personal bookshelf. Check out Excel 2013 Power Programming with VBA today!

Combining Numbers and Text in a Cell

There are times when it can be beneficial to combine both numbers and text in the same cell. This can be easily done ...

Discover More

Filling References to Another Workbook

When you create references to cells in other workbooks, Excel, by default, makes the references absolute. This makes it ...

Discover More

Determining "Highest Since" or "Lowest Since"

When compiling statistics on a collection of data points, you may want to know whether a particular value is the "highest ...

Discover More
##### Subscribe

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

If you would like to add an image to your comment (not an avatar, but an image to help in making the point of your comment), include the characters [{fig}] (all 7 characters, in the sequence shown) in your comment text. Youâ€™ll be prompted to upload your image when you submit the comment. Maximum image size is 6Mpixels. Images larger than 600px wide or 1000px tall will be reduced. Up to three images may be included in a comment. All images are subject to review. Commenting privileges may be curtailed if inappropriate images are posted.

What is 1 - 0?

There are currently no comments for this tip. (Be the first to leave your commentâ€”just use the simple form above!)

##### This Site

Got a version of Excel that uses the menu interface (Excel 97, Excel 2000, Excel 2002, or Excel 2003)? This site is for you! If you use a later version of Excel, visit our ExcelTips site focusing on the ribbon interface.

##### Subscribe

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