Training & Facilitation

Excel: Last Value in a Range

Find the last value in a row or range in Excel. Smart formulas using LOOKUP and nested IFs to return the last non-zero or non-blank value.

A woman working in Excel on a computer.

From time to time, we need a formula returning only the last value in a row range, when ranges grow rightwards, and daily, as in values for Monday thru Friday in a range. If there are dates in headers, it’s easy to test for latest date, but sometimes there’s no such help. The most concise I have found is the following:

=LOOKUP(9.99E+307,A1:H1)

ROW 1

The number 9.99E+307 is too large for Excel to process, and therefore isn’t found. When LOOKUP can’t find a lookup value in a range, it returns the last value found in that range. That’s what we have here in cell I1. Caveat: if there were a formula in cell H1 the example, and that formula returned a blank or a zero, cell, LOOKUP would return zero. So it’s best used with blank cells.

ROW 3

A formula returns zero in cell H3. This longer formula works correctly, because it tests each cell for zero, returning non-zero value if true. Value in H3 will only be returned if it were non-zero, so the formula correctly returns the last non-zero value (in G3).

The formula here is:

=IF(H3=0,IF(G3=0,IF(F3=0,IF(E3=0,IF(D3=0,IF(C3=0,IF(B3=0,IF(A3=0,0,A3) ,B3),C3),D3),E3),F3),G3),H3)

Looking for a software partner?

Tell us about your project and we’ll show you how our team can help.

Contact Us

Found this useful? Share it.

Written by

KRS

More musings →

Keep reading

Selection of software book covers in a collage Training & Facilitation

27 May 2025 · Lor Steyn

Our recommended books for writing better code

Our top recommended books to improve code quality, design, and organisation, from DDD and TDD to software design classics and best practices.

Minimum Viable Product - MVP Training & Facilitation

1 December 2022 · KRS

Define your Minimum Viable Product (MVP) with KRS

KRS has proven processes to identify your MVP (Minimum Viable Product). Get your product to market as soon as possible with our expertise

KRS Product Owner Graphic Training & Facilitation

29 October 2022 · KRS

KRS Product Owner services in a nutshell

KRS provides clients with senior Product Owner services - a key role in the development and successful delivery of a software solution.