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

by Allen Wyatt
(last updated January 30, 2020)


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:


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:


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:


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:


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:

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. ...


Italic Typing Doesn't Stay Italic

If you turn explicit formatting on and off as you type, you may notice some quirky behavior in Word. This tip examines ...

Discover More

Getting Audible Feedback

Want to get a little bit of sound with your data? Excel can provide audible feedback that you may find helpful. Here's how.

Discover More

Updating Automatically when Opening Under Macro Control

If your workbook contains links, you are normally given the opportunity to update those links when you open the workbook. ...

Discover More

Create Custom Apps with VBA! Discover how to extend the capabilities of Office 2013 (Word, Excel, PowerPoint, Outlook, and Access) with VBA programming, using it for writing macros, automating Office applications, and creating custom applications. Check out Mastering VBA for Office 2013 today!

More ExcelTips (menu)

Calculating the Distance between Points

Want to figure out how far it is between two points on the globe? If you know the points by latitude and longitude, you ...

Discover More

Determining Business Quarters from Dates

Many businesses organize information according to calendar quarters, especially when it comes to fiscal information. ...

Discover More

Splitting Cells by Case

Excel provides several different ways that you can split apart the contents of a cell. One way it doesn't provide is to ...

Discover More

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

View most recent newsletter.


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 four less than 7?

2021-03-02 02:45:39

Jayne A Garnett

Many thanks for your reply. I'm using Excel on a MacBook so I tried using a Windows pc with the recommended formula and then sending the spreadsheet to the MacBook, copying the formula into the original spreadsheet and it worked. On copy and paste the formula was amended automatically to include the @ sign as below. It must be an issue using Excel for Mac, very frustrating but got there in the end :-)


2021-02-28 14:59:53

P de la Court

Hi Jayne,

Try this formula: =LOOKUP(2,1/(1-ISBLANK(D3:D22)),D3:D22)

2021-02-27 09:49:36

Jayne A Garnett

Hi all, I've been going crazy trying to fix this, I want cell D23 to return the latest value in column D, for example each time I populate the daily market value I want cell D to pick up the latest price, in this case the value on 26 February, in this case EUR 1,016.75 (see Figure 1 below)
Thank you!

Figure 1. Example

2021-02-27 07:10:46

Jayne A Garnett

Hi all, I've been going crazy trying to fix this, I want cell D23 to return the latest value in column D, for example each time I populate the daily market value I want cell D to pick up the latest price, in this case the value on 26 February, in this case EUR 1,016.75 (see Figure 1 below)
Thank you!

Figure 1. Example

2021-01-21 21:23:02

Samuel D Penaranda

Please if anyone can help me I would appreciate it. I have been trying to get the last value in a column (column P) that goes from cell 7 to cell 43. My last number is in cell P32. I applied the formula "INDEX((P7:P43),COUNT(P7:P43))", and I get the corresponding values however using the other possible formulas I get a blank cell as result. When applying the formula "LOOKUP(2,1/(1-ISBLANK(P7:P43)),P7:P43)" i get a blank cell. When I applyed the formula "LOOKUP(2,1/(p7:p43<>0),P7:P43)" and also I got a blank cell. I would like to understand why I get a blank cell when using certain formulas but the correct value when using the "INDEX........." formula above, I understand all these formulas should work the same or give the same result. Am I misunderstanding something? Or I am doing something wrong.

2020-12-17 12:57:51


Thanks, the below helped me out, but I think you may be missing [+1] for zero-indexed column values.


2018-10-22 04:54:34


Oops. Copy and paste error. The formula I gave is for summing an entire column except the last value (copied from one of my spreadsheets). So tha formula to just retrieve the last cell value is simply:

VLOOKUP(1E+99, A:A, 1)

2018-10-22 04:47:51


Rather than using lookup , which is now provided only for backward compatibity, it is preferable to use vlookup as in the following formula:

=SUM(A:A) - VLOOKUP(1E+99,A:A, 1)

2018-06-18 07:28:12


Using excel formula, how to validate if the last value in a row (or column) is greater than the previous one?


Row 1 ---------100------------97------------78-----------87------------56-------------78----
Row 2-----Result:------------Yes (78 is greater than 56)

I need formula, please...

2018-04-02 16:14:23

not strong on VBA user

I have an excel sheet where I need the value in cell B2 to continue from wherever the B column in the previous sheet left off.
The values are in column B follow this format:

Is this possible?

2017-11-01 04:07:00

Michael (Micky) Avidan

@Mark Walters,
To my opinion - the following formula will do the job for all kind of situations (in column E)
Michael (Micky) Avidan
“Microsoft® Answers" - Wiki author & Forums Moderator
“Microsoft®” Excel MVP – Excel (2009-2018)

2017-10-31 12:28:19

Mark Walters

I liked the first formula but my data did not start in the first row but in row 12. In case someone else has the same requirement, no problem, just tweak the formula to something like this:


I.e. the data is in column "E" and row 12, and will work so long as it ends before row 201, if you want to allow for more data, just change the "200" to your own value (remember to change both values).

2017-04-12 15:09:42


Hi sir, what if i want to highlight the last value in a cell which is greater than 200 ? What would be the formula?

2016-09-28 09:53:56

Joe S

Thanks! This worked perfectly for me. I just had to add in what worksheet I was pulling the data from and everything is good to go!

2016-08-11 15:51:28


A variant to the original formula gives the row number instead of the value of the last filled row:
This can be used to construct the address of that cell.

2016-08-10 16:48:58


=LOOKUP(2,1/(1-ISBLANK(A:A)),A:A) this formula works perfectly fine. My question is how to get a reference of a last cell which loopup found.


2016-03-30 10:34:18

Bruce Johnson

Please help, I have a multi-tab spreadsheet. One tab is my Totals spreadsheet and the other is my IRA's. On my Totals spreadsheet I want to sum of the last entries of two different columns on my IRA's spreadsheet. These last entries are not a total of their respective previous entries, they are just the current asset values. So I am trying to sum the last entry of IRA-a and IRA-b on my totals tab.

2016-03-30 03:34:45


Many thanks for this useful and very clear article!

2016-03-03 12:28:41

J. E. Dixon

I need a VB code to let me do the following: 1) Select a variable range from a column of cells (call it the High’s column) – I would like to be able to change this manually at the start of this activity; 2) Find the maximum numeric value in that range (Max 1) and place this in another column on the same worksheet; 3) Record the row number and date of that cell from adjacent columns to that cell on the applicable worksheet in two different columns; 4) Reset the start of the variable range to the maximum value just found in step # 2; 5) Find the next cell maximum (Max # 2) and record this value in the same column but next cell as Max #1; 6) Record the row number and date of that cell from adjacent columns to that cell on the applicable worksheet in in the same column but next cell as the row number and date recorded in step # 3; 7) Calculate the number of cells between the maximums and record this on worksheet # 2; 8 ) Make a loop and find the next maximum, date and row number for max # 3 and record these as above; 9) Do all of these steps until all data has been examined; 10) For those ranges when no other maximum found in the variable range, go to the next variable range until another maximum is found; 11) include the # of rows in step 10 plus those for this step in the columns used for other data maximums as above.

2015-12-01 06:50:00


Hi there

I have a workbook with about 300+ sheets. Each sheet shows certain details about a certain site. The column headers are the same for each sheet, but the number of rows for each sheet is different.

Basically I have the starting sheet with a list of all the site names (sheet names) and I would like to be able to get the last value of every column from L onwards. in this case it will be column L to AQ. This part is pretty straight forward using either lookup, or even index if you can get it right. The problem I have is to be able to drag across to get the last value of each column and then to be able to drag down to retrieve this for each sheet.

Does anyone know to go about this without entering sheet names and cell numbers manually? Any help would be greatly appreciated.


2015-10-07 11:49:07


Phil - Same for me.

Kenan - let me respond to your "hope this helps" with a value from your table..."no"

2015-08-04 06:27:10


Thanks, a modified version of =LOOKUP(2,1/(1-ISBLANK(A:A)),A:A) worked for me also.

2015-07-31 05:49:51

Pieter de la Court

Peter, that formula COUNTA(A:A) only counts filled cells. Therefore, if you have empty rows in column A, the result will come out wrong.

2015-07-31 03:10:21


Excellent... This one worked exactly according my requirement.



2015-07-09 11:13:01


aaa 1/1/2015 500 yes
aaa 1/2/2015 501 yes
aaa 1/3/2015 502 yes
aaa 1/4/2015 503 yes
aaa 1/5/2015 504 yes
aaa 1/6/2015 505 yes
aaa 1/7/2015 506 yes
aaa 1/8/2015 507 yes
aaa 1/9/2015 508 yes
aaa 1/10/2015 509 yes
aaa 1/11/2015 510 yes
aaa 1/12/2015 511 yes
aaa 1/13/2015 512 no
bbb 1/14/2015 513 yes
bbb 1/15/2015 514 yes
bbb 1/16/2015 515 yes
bbb 1/17/2015 516 yes
bbb 1/18/2015 517 yes
bbb 1/19/2015 518 yes
bbb 1/20/2015 519 yes
bbb 1/21/2015 520 yes
bbb 1/22/2015 521 yes
bbb 1/23/2015 522 no

to get the last record from this table
sort it.. the sort will be done on 1st column and then on date..
then you use the if function which is
=IF(A1=A2,"yes","no") .. where you see no is the last record..
hope this helps.

2015-04-03 19:53:48


The first one works much better if you use COUNTA. INDEX(A:A,COUNTA(A:A)) this will return the last cell with anything in it text or not.

For the last three entries hans try =CONCATENATE(INDEX(A:A,COUNTA(A:A))," ",INDEX(A:A,COUNTA(A:A)-1)," ",INDEX(A:A,COUNTA(A:A)-2)). This will put them one after the other with spaces in between

2015-03-01 06:10:10


Look like problem tht I have..i need the last 3 entries from colomn A.
Numeric-nonnumeric entries..thanks

2015-01-30 12:24:54

Willy Vanhaelen

You can even make it shorter:


2015-01-29 00:19:45

Ramanand Shetty

what I wanted was
coz I just wanted last vlaue in coloumn, it would hv either number or any value...
thank you :) :) :)

2014-11-02 05:18:44

Pieter de la Court

For me (Excel 2003) the formula =LOOKUP(2,1/(1-ISBLANK(A:A)),A:A) gives me the content of the first cell (A1) instead of the last filled cell. Changing the formula to =LOOKUP(2,1/(1-ISBLANK(A1:A65535)),A1:A65535) solves this problem. Any idea why?

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.

Newest Tips

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

(Your e-mail address is not shared with anyone, ever.)

View the most recent newsletter.