Microsoft Office Tutorials and References
In Depth Information
Tip 41: Returning the Last Nonblank Cell in a Column or Row
Returning the Last Nonblank Cell in a
Column or Row
Suppose that you update a worksheet frequently by adding new data to its columns. You might need
a way to reference the last value in a particular column (the value most recently entered). This tip
presents three ways to accomplish this.
Figure 41-1 shows an example. The worksheet tracks the value of three funds in columns B:D. Notice
that the information does not arrive at the same time. The goal is to get the sum of the most recent
data for each fund. These values are calculated in the range G4:G6.
Figure 41-1: Use a formula to return the last non-empty cell in columns B:D.
Cell counting method
The formulas in G4, G5, and G6 are
=INDEX(B:B,COUNTA(B:B))
=INDEX(C:C,COUNTA(C:C))
=INDEX(D:D,COUNTA(D:D))
These formulas use the COUNTA function to count the number of non-empty cells in column C. This
value is used as the second argument for the INDEX function. For example, in column B the last value
is in row 6, COUNTA returns 6, and the INDEX function returns the 6th value in the column.
The preceding formulas work in most, but not all, situations. If the column has one or more empty
cells interspersed, determining the last nonblank cell is a bit more challenging because the COUNTA
function doesnâ€™t count the empty cells.
Search JabSto ::

Custom Search