Yes, you can create a formula that automatically detects the last entry in a column. This is most commonly done using the INDEX and MATCH functions combined with the COUNTA function to find the last non-empty cell. Alternatively, for Excel 365 or Excel 2021+, the dynamic array function TAKE provides a simpler syntax. These formulas allow you to reference or process the data at the bottom of a list without manually typing cell references like Z10.

What You'll Need

  • A computer running Microsoft Excel (2019, 2021, or Microsoft 365 versions are recommended for the easiest methods, though the INDEX/MATCH method works in older versions).
  • A spreadsheet with some data in a column. The formula will find the last cell that contains text, numbers, or formulas, but it ignores completely empty cells.
  • Basic knowledge of how to enter a formula into a cell.

Step-by-Step

  1. Open your spreadsheet and navigate to the cell where you want the result. This cell will display the value from the last row of your data column.
  2. Enter the INDEX and MATCH formula. Type the following into the cell, replacing A:A with the column letter containing your data (e.g., B:B for column B). This formula finds the last non-empty cell in the column and returns its value.
  3. =INDEX(A:A, MATCH(9.99E+307, A:A, 1))

    Explanation of the formula:

    • A:A: The range to search.
    • MATCH(9.99E+307, A:A, 1): 9.99E+307 is an extremely large number that is larger than any date or number in standard Excel. The MATCH function looks for this number in the column and returns the position of the last item it finds. The 1 at the end tells Excel to search for a match in ascending order.
    • INDEX(A:A, ...): The INDEX function takes the column and the position found by MATCH to return the actual value.
  4. Press Enter. The cell will now display the value from the last row of your data.
  5. Copy the formula down to other cells if needed. If you want to use this formula to dynamically reference other columns based on the last row, you can lock the column reference and use relative row references.
  6. For example, if your data is in column A and you want to reference the value in column B for the same row, enter the following formula in cell C1:

    =INDEX($A:$A, MATCH(9.99E+307, $A:$A, 1)) (This gets the last A value)

    Then, in cell B2, enter:

    =INDEX($B:$B, MATCH(9.99E+307, $A:$A, 1))

    Or, to combine them into a single cell that shows the last A value and the last B value:

    =INDEX($A:$A, MATCH(9.99E+307, $A:$A, 1)) & " | " & INDEX($B:$B, MATCH(9.99E+307, $A:$A, 1))

  7. Using the dynamic array TAKE function (Excel 365/2021+). If you have a newer version of Excel, you can use a much shorter formula.
  8. Type the following into the cell:

    =TAKE(A:A, -1)

    This formula simply takes the last item from the list. Note that TAKE returns a spill range if the source is a spill range, so ensure there is enough empty space below it.

  9. Using the dynamic array DROP function (Excel 365/2021+). Another way to get the last item is to drop all items except the last one.
  10. Type the following into the cell:

    =DROP(A:A, -1)

    This returns an array containing only the last value.

Common Mistakes

One of the most frequent errors when using the INDEX and MATCH method is using the MATCH function with the 0 argument (exact match). This will fail because the formula is looking for an exact match of the large number 9.99E+307, which likely doesn't exist in your data, and will return a #N/A error. The 1 argument (ascending order) is crucial for this trick to work.

Another common mistake is not accounting for blank cells. If you have a column with data, then a blank row, then more data, the formula will stop at the blank row. The COUNTA function is sometimes used with INDEX to count non-empty cells, but the MATCH method described above is generally more robust for finding the last entry.

Tips

When referencing this formula in another part of your sheet, always lock the column reference (use the dollar sign, e.g., $A:$A). This ensures that when you copy the formula to the right or down, it continues to look at the correct column for the last entry.

For text data, the 9.99E+307 number trick works perfectly. However, if your column contains dates, ensure they are formatted as dates and not text. If your column contains a mix of numbers and text, the number trick will still find the last item in the order they appear, which is usually what you want.

Troubleshooting

If your formula returns a #N/A error, check that you are using the 1 argument in the MATCH function. If you are using the TAKE or DROP functions and get a #SPILL! error, it means there is data below your formula that is blocking it from displaying the result.

If the formula returns an unexpected value or an error after adding new rows, ensure that you are not including the header row in your range (e.g., use A2:A100 instead of A:A). If you want to include the header row as part of the data, you can adjust the range accordingly.

Frequently Asked Questions

How do I get the last cell address (A1, A2, etc.) instead of the value?

You can use the ADDRESS function combined with the MATCH function. The formula would be: =ADDRESS(MATCH(9.99E+307, A:A, 1), COLUMN(A:A)). This returns a text string like "A10".

Does this work if the column has filters applied?

No. The MATCH function looks at the raw data in the column. If you filter the column, the formula will still find the last entry in the raw data, not the last visible entry. To work with filtered data, you would need to use a more complex array formula or a macro.

Can I use this to sum values in the last 10 cells?

Yes. You can use the INDEX function to create a dynamic range and then sum it. For example, to sum the last 10 values in column A: =SUM(INDEX(A:A, MATCH(9.99E+307, A:A, 1)-9):INDEX(A:A, MATCH(9.99E+307, A:A, 1))). This uses the index of the last item to calculate the start of the range 9 rows above it.

Why does my formula return an error if the column is completely empty?

The MATCH function requires at least one value to find. If the column is empty, it will return a #N/A error. You can wrap the formula in an IFERROR function to handle this case, e.g., =IFERROR(INDEX(A:A, MATCH(9.99E+307, A:A, 1)), "No Data").

Is there any performance issue with using the whole column range (A:A)?

Using the whole column range can slow down your spreadsheet if you have a very large dataset (e.g., millions of rows). For large datasets, it is better to define a specific range (e.g., A2:A100000) to improve calculation speed.