VBA Select First Empty Cell in Column

VBA & macros · Updated November 23, 2026

The fastest way to select the first empty cell in a column with VBA is to use Range("A1").End(xlDown).Offset(1).Select for a contiguous block of data, or Cells(Rows.Count, 1).End(xlUp).Offset(1).Select for a column with gaps. The second method is more reliable for most real-world sheets.

Why the Simple End(xlDown) Approach Can Fail

Many tutorials suggest Range("A1").End(xlDown).Offset(1).Select. This works like pressing Ctrl+Down on the keyboard: it jumps from the starting cell to the last cell before a blank in that direction. If your column has no blank cells between the header and the last data row, it finds the last used cell and Offset(1) moves one row below it—exactly what you want.

But if there is any blank row inside your data (a common occurrence), End(xlDown) stops at that first blank, not the true last row. For example, if A1:A5 have values and A6 is blank, Range("A1").End(xlDown) returns A5, and Offset(1) selects A6—which is indeed the first empty cell. However, if your data has a blank at A3, it stops at A2, and you end up selecting A3, which is the first empty cell, but that might not be where you want to add new data if the rest of the column continues below. The method only finds the first empty cell after the starting point, not the first empty cell after the last contiguous block of data.

The Robust Method: End(xlUp) from the Bottom

The standard, reliable way to find the first empty cell in a column is to start from the very bottom of the worksheet and move upward, then step one row down. In Excel, the maximum row number is 1,048,576 (for Excel 2007 and later). So you use Cells(Rows.Count, 1) to reference the last cell in column A, then .End(xlUp) to jump to the last non-empty cell in that column, and .Offset(1) to move to the next row.

Sub SelectFirstEmptyCell()
    Dim ws As Worksheet
    Dim lastRow As Long
    
    ' Save a copy of your workbook before running any macro
    Set ws = ThisWorkbook.Sheets("Sheet1")
    
    ' Find the last used row in column A
    lastRow = ws.Cells(ws.Rows.Count, "A").End(xlUp).Row
    
    ' Select the cell one row below the last used cell
    ws.Cells(lastRow + 1, "A").Select
End Sub

This works regardless of blank cells in the middle of your data because it starts from the bottom and looks up, so it always finds the last row that has any value in that column. The Offset(1) then moves to the first truly empty cell below that.

Using Find to Handle Completely Empty Columns

If the column is completely empty, End(xlUp) from the bottom will return row 1 (the first row), and Offset(1) will give row 2. That might be fine, but if you want to start at row 1, you need a different approach. A more robust way is to use the Find method, which can also detect if there is any data at all.

Sub SelectFirstEmptyCellWithFind()
    Dim ws As Worksheet
    Dim firstCell As Range
    
    Set ws = ThisWorkbook.Sheets("Sheet1")
    
    ' Find the last cell with any value in column A
    Set firstCell = ws.Columns("A").Find(What:="*", _
                    After:=ws.Cells(1, 1), _
                    LookIn:=xlValues, _
                    LookAt:=xlWhole, _
                    SearchOrder:=xlByRows, _
                    SearchDirection:=xlPrevious)
    
    If firstCell Is Nothing Then
        ' Column is empty, so first empty cell is A1
        ws.Range("A1").Select
    Else
        ' Move one row below the last found cell
        ws.Cells(firstCell.Row + 1, 1).Select
    End If
End Sub

This code uses Find with a wildcard "*" to search for any cell that contains text, numbers, or errors. It searches backward from the last cell in the column, so it finds the last non-empty cell. If nothing is found, the column is empty and you select A1.

Selecting vs. Activating: What’s the Difference?

In VBA, Select is not always necessary. If you only need to write a value into the first empty cell, you can skip selecting and directly assign the value. Selecting is only required if you want the user to see the cell highlighted on screen. Overusing Select can slow down your macro, especially if you are looping through many cells.

For most operations, you can do this without selecting:

Sub WriteToFirstEmptyCell()
    Dim ws As Worksheet
    Dim lastRow As Long
    
    Set ws = ThisWorkbook.Sheets("Sheet1")
    lastRow = ws.Cells(ws.Rows.Count, "A").End(xlUp).Row
    
    ' Write a value directly to the first empty cell
    ws.Cells(lastRow + 1, "A").Value = "New Data"
End Sub

This is faster and cleaner. Use Select only when you genuinely need to move the user’s cursor.

Handling Different Columns and Worksheets

The same logic works for any column. Replace the column letter in the Cells reference. For example, to find the first empty cell in column D, use ws.Cells(ws.Rows.Count, "D").End(xlUp).Row. If you are working with the active sheet, you can omit the ws variable and use ActiveSheet, but it’s safer to explicitly reference a worksheet to avoid errors if the user switches sheets while the macro runs.

If your data starts at a row other than 1 (e.g., there is a title in row 1), you might want to adjust the starting point. The End(xlUp) method from the bottom will always find the last used row in the entire column, including any headers. If you want to skip the header, you can add an offset after finding the last row, or use a fixed starting row like Range("A2").End(xlDown) but that has the same blank-cell issue. A common pattern is to find the last row in the column, then if that row is the header (row 1), you know the column is empty except for the header.

Common Problems and How to Avoid Them

  • Selecting a cell that is not visible: If the worksheet is filtered, Select might fail or select a hidden cell. Use Activate instead, or temporarily disable filters.
  • Using End(xlDown) on a column with blanks: As mentioned, this stops at the first blank. Always use End(xlUp) from the bottom for the true last row.
  • Forgetting to save a copy of your workbook: Macros cannot be undone with Ctrl+Z. Always save a backup before running any VBA that modifies data.
  • Hard-coding row 1048576: Use Rows.Count to be compatible with older Excel versions (which had 65,536 rows).
  • Selecting a cell in a different sheet: If you don’t activate the worksheet first, Select will fail. Use ws.Activate before selecting, or use ws.Cells(...).Select which works even if the sheet is not active (as long as the workbook is active).

Frequently Asked Questions

How do I select the first empty cell in a row instead of a column?

For a row, use Cells(1, Columns.Count).End(xlToLeft).Offset(0, 1).Select. This starts at the last column in row 1 and moves left to find the last used cell, then steps one column to the right.

Can I use this to find the first empty cell in a column that has formulas?

Yes, End(xlUp) considers cells with formulas as non-empty, even if the formula returns an empty string. If you want to treat formulas that return “” as empty, you need to loop through the cells and check the value, or use SpecialCells with constants.

Why does my macro select the wrong cell when I use End(xlDown)?

Because End(xlDown) stops at the first blank cell. If your data has any blank rows, it will stop there. Use End(xlUp) from the bottom to get the true last row.

Is there a way to select the first empty cell without using Select?

Yes, you can directly reference the cell and perform an action, like writing a value. Selecting is only needed if you want to visually highlight the cell.

What if the column is entirely empty?

Use the Find method as shown above. If Find returns Nothing, the column is empty, and you can select A1 (or whatever your starting row is).

Alternatives to VBA for Finding the First Empty Cell

If you want to avoid VBA, you can use Excel formulas. To get the row number of the first empty cell in column A, you can use an array formula like =MATCH(TRUE,ISBLANK(A:A),0) (entered with Ctrl+Shift+Enter in older Excel, or just Enter in Excel 365). This returns the row number of the first blank cell. However, this formula considers any blank cell, not just the one after the last data. For a more robust approach, use =MIN(IF(A:A="",ROW(A:A))) as an array formula, which gives the first blank row. But these formulas can be slow on large columns.

Another non-VBA method is to use Go To Special > Blanks (Home > Editing > Find & Select > Go To Special > Blanks). This selects all blank cells in the selected range, but not just the first one. You can then press Tab to move to the first blank cell in the selection.

Related

Try it: the Column Letter to Number: aA is 27, XFD is 16,384. Converts both ways.

More in VBA & macros

Sources: Function behaviour and menu paths: Microsoft Support documentation for Excel. Method & sources

Spotted an error in this guide? Let us know.