Excel VBA: Select the First Blank Cell After the Last Row
Question details
The user wants a VBA macro to select the first blank cell below the last populated row in a column.

- Product
- Microsoft Excel
- Device & OS
- not provided
- Scenario
- After pasting a column of data, the user wants to move the cursor to the next row below that data.
- Observed behavior
- The desired selection is the cell immediately below the column's last populated cell, rather than a blank cell within the data.
Identify the column to search and make sure the worksheet containing the pasted data is active. If you want to retain the macro, save the workbook as an Excel Macro-Enabled Workbook (.xlsm).
Run a VBA macro to select the cell below the last used row
Use this macro to select the next cell in column A, including when the column is empty.
The macro searches upward from the bottom of column A. It selects the cell after the last populated row, not the first gap within the data.
In Excel, open Developer > Visual Basic, then choose Insert > Module.
Paste this code into the module: Sub SelectNextBlank() Dim ws As Worksheet Dim nextRow As Long Set ws = ActiveSheet If Application.WorksheetFunction.CountA(ws.Columns("A")) = 0 Then nextRow = 1 ElseIf Not IsEmpty(ws.Cells(ws.Rows.Count, "A").Value) Then MsgBox "There is no row below the last populated cell." Exit Sub Else nextRow = ws.Cells(ws.Rows.Count, "A").End(xlUp).Row + 1 End If ws.Cells(nextRow, "A").Select End Sub
Return to the worksheet, choose Developer > Macros, select SelectNextBlank, and click Run. To search another column, replace each "A" in the code with that column's letter.

Select the next blank row in WPS Spreadsheets
In a WPS Office installation that supports VBA macros, use the same last-row approach in WPS Spreadsheets to select the cell below your pasted data. VBA availability and compatibility can vary by version and platform.
- 1. Open the workbook: Open your workbook in WPS Spreadsheets and select the worksheet containing the data.
- 2. Open the macro editor: If your WPS installation supports VBA, open Developer > Visual Basic and choose Insert > Module.
- 3. Add the code: Paste the SelectNextBlank macro from the solution above into the module, changing column A if needed.
- 4. Run and save: Choose Developer > Macros, select SelectNextBlank, and click Run. Save the workbook as XLSM if you need to retain the macro.

Frequently Asked Questions
How do I find the next blank cell in a different column?
In the macro, replace every "A" with the desired column letter. For example, use "B" to search column B, then run the macro from Developer > Macros.
What happens if the column is completely empty?
The macro checks the column with CountA and selects its first row, such as A1 for column A.
Will the macro select a blank cell between two values?
No. It searches upward from the bottom of the worksheet and selects the cell below the last populated row, even if there are gaps above it.
How do I keep the macro in my Excel workbook?
Choose File > Save As and select Excel Macro-Enabled Workbook (.xlsm). Enable macros only when you trust the workbook and its source.
Can I use the macro in every version of WPS Spreadsheets?
Not necessarily. VBA support varies by WPS version and platform. Check whether Developer > Visual Basic is available in your installation before using the macro.




