How to Remove Blank Lines in Excel
Blank rows in an Excel spreadsheet are more than a cosmetic annoyance - they break SORT, they confuse AutoFilter into treating your data as several smaller ranges instead of one table, and they can silently truncate formulas that reference a contiguous range. If your data started life as a pasted export or a merge of several sources, blank rows are almost guaranteed. Here are two ways to get rid of them, from quickest to most repeatable.
Method 1: Find & Replace (Go To Special)
This is the method most people search for, and it doesn't require touching a single formula or macro.
- Select the range containing your data (or select the whole sheet with
Ctrl+Aif you're not sure of the exact bounds). - Press
Ctrl+Gto open "Go To," then click "Special..." (or use the Home tab → Find & Select → Go To Special). - Choose "Blanks" and click OK. Excel selects every empty cell within your original selection.
- Right-click any of the selected cells → Delete... → "Entire row" → OK.
One thing worth knowing before you do this: "Go To Special > Blanks" selects empty cells, not necessarily entirely blank rows. If a row has some cells filled and others empty, those empty cells get selected too, and deleting "entire row" will remove rows that aren't actually fully blank - just partially. For data where every row is either completely empty or completely filled, this isn't a problem. For messier data, check your selection in the Name Box (top-left) before deleting, or use a helper column with a COUNTA formula to flag truly blank rows first, then filter and delete based on that instead.
Method 2: VBA macro (for repeated use or larger datasets)
If you're cleaning up blank rows regularly, or working with a dataset too large to comfortably eyeball before deleting, a macro is faster and more precise:
Sub DeleteBlankRows()
Dim i As Long
Dim lastRow As Long
lastRow = Cells(Rows.Count, 1).End(xlUp).Row
For i = lastRow To 1 Step -1
If Application.WorksheetFunction.CountA(Rows(i)) = 0 Then
Rows(i).Delete
End If
Next i
End SubWhat this does: it finds the last used row in column A, then loops from that row backwards up to row 1 (For i = lastRow To 1 Step -1), checking each row withCountA - a function that counts non-empty cells. If a row has zero non-empty cells (= 0), it's genuinely blank across every column, and the macro deletes it.
The pitfall worth knowing: if you loop top-to-bottom instead and delete a row as you go, every row below the one you just deleted shifts up by one - but your loop counter keeps incrementing as if nothing moved. The result is that you silently skip the row immediately after every deletion, leaving some blank rows behind. Looping backwards (bottom-to-top, as this macro does) sidesteps the problem entirely: deleting row 50 only affects rows below 50, which your loop has already passed, so nothing gets skipped.
To use it: open the VBA editor (Alt+F11), insert a new module (Insert → Module), paste the code in, close the editor, then run it from Excel via Alt+F8 → select DeleteBlankRows → Run.
Skip Excel entirely
If your data started as pasted or copied text before it became a spreadsheet - a list of names, a CSV export, log lines, anything that isn't inherently tabular - you might not need Excel for this step at all. Remove Blank Lines does the same cleanup on raw text directly in your browser, before you even paste it into a spreadsheet.
This guide is part of our full roundup offree tools for cleaning up messy text, covering duplicate lines, blank lines, extra spaces, and dirty CSV exports.
Frequently Asked Questions
Why does Go To Special > Blanks sometimes select more than I expect?
It selects every empty cell within your selection, not just rows that are entirely blank. If a row has a mix of filled and empty cells, its empty cells get selected too - which means deleting "entire row" afterward can remove rows that had real data in some columns. Check your selection before deleting if your data isn't consistently all-or-nothing per row.
Can I undo this if I delete the wrong rows?
Yes, immediately after with Ctrl+Z, same as any other Excel action - but only until you save or close the file. If you're working with important data, it's worth duplicating the sheet or saving a copy before running either method for the first time.
Does the VBA macro work if my data doesn't start in column A?
The macro checks Cells(Rows.Count, 1) to find the last row, which assumes column A has data down to the bottom of your range. If your first populated column is different, change the 1 in that line to match (e.g., 3 for column C). The blank-row check itself (CountA(Rows(i)) = 0) scans the entire row regardless, so that part doesn't need adjusting.
Why does looping backwards matter so much?
Because Excel doesn't renumber your loop counter when a row is deleted - it renumbers the rows. If you delete row 10 while counting upward, everything below shifts up by one, so what was row 11 is now row 10, but your loop is already moving on to check row 11 next - which is actually the old row 12. That's how rows get silently skipped. Counting downward avoids this because deleting a row never affects the numbering of rows above it, which is the direction your loop is heading next.
Is there a way to do this without VBA if I don't want to enable macros?
Yes - Method 1 (Go To Special > Blanks) requires no macros or special permissions, and works for one-off cleanup. VBA is only worth the setup if you're doing this often enough that automating it saves real time, or your files are consistently large enough that manual selection becomes error-prone.