How to delete infinite rows in excel
Tutor 5 (273 Reviews)
Excel Tutor
Still stuck with a Excel question
Ask this expertAnswer
“Infinite rows” means the large number of blank rows below your used data area that make the sheet look huge. Excel’s worksheet grid always shows up to 1,048,576 rows. You cannot change that maximum, but you can remove data, formatting, and the workbook’s used range so the sheet behaves like it has fewer rows, and the file size shrinks.
Why remove unused rows?
Removing unused rows can:
-
Reduce file size when excessive formatting or stray data extends the used range.
-
Improve workbook performance during calculations and scrolling.
-
Make printing and navigation easier.
Precautions before you start
-
Create a backup copy of the workbook.
-
Save a copy before running macros.
-
Check formulas and named ranges that might reference rows you plan to remove.
How to delete all unused rows below your data (quick method — Windows and Mac)
-
Click the first blank row below your data.
-
Press and hold
Ctrl+Shift+Down Arrowon Windows. On Mac, pressControl+Shift+Down ArroworFn+Control+Shift+Down Arrowdepending on your keyboard. -
Right-click any selected row number and choose Delete from the context menu.
-
Save the workbook, then close and re-open it to let Excel reset the used range.
How to delete unused rows using the Name Box (precise selection)
-
Click the row number of the first blank row below your data (for example, row 101).
-
In the Name Box (left of the formula bar) type
101:1048576and press Enter. -
Right-click any selected row number and choose Delete.
-
Save, close, and re-open the workbook.
How to clear stray formatting before deleting (important for reducing file size)
-
Select a small area in the sheet that definitely contains no content (for example, first blank row).
-
Press
Ctrl+Shift+Endto check what Excel considers the used range. -
Select rows/columns beyond your actual data, then use Home → Clear → Clear Formats to remove stray formatting.
-
After clearing formatting, delete the rows using one of the methods above, then save, close, and re-open.
How to delete all blank rows within a data range (remove empty rows among data)
-
Select the entire data range, or press
Ctrl+Ainside the data. -
On the Home tab select Find & Select → Go To Special → Blanks → OK.
-
On the Home tab choose Delete → Delete Sheet Rows.
-
Verify results, then save the workbook.
How to delete unused rows with a VBA macro (power method)
-
Press
Alt+F11on Windows. On Mac useOption+F11or Developer → Visual Basic. -
Insert a new module and paste this macro:
-
Open the Visual Basic Editor.
-
Insert → Module.
-
Paste the code below.
-
-
Run the macro on the sheet you want to clean.
-
Save, close, and re-open the workbook.
Sub DeleteRowsAfterLastUsed()
Dim ws As Worksheet
Dim LastRow As Long
Set ws = ActiveSheet
On Error Resume Next
LastRow = ws.Cells.Find(What:="*", LookIn:=xlFormulas, _
LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row
If LastRow < ws.Rows.Count Then
ws.Rows(LastRow + 1 & ":" & ws.Rows.Count).Delete
End If
On Error GoTo 0
End Sub
What the macro does
The macro finds the last cell with content and deletes every row below it. The macro does not change Excel’s maximum row count, but it removes content and resets the used range for that sheet.
Windows vs Mac differences
-
Keyboard shortcuts: Windows uses
CtrlandAlt; Mac usesControl,Option(Alt),CommandorFndepending on the keyboard. -
Alt+F11opens the VBA editor on Windows. On many Macs useOption+F11or open Developer → Visual Basic. -
Name Box and Ribbon locations are the same across platforms; menu names match in modern Excel.
When deleting rows will not reduce file size
-
Deleting rows will not shrink file size if formatting or objects are stored elsewhere in the workbook.
-
Complex features such as conditional formatting, charts, shapes, or many hidden worksheets can keep file size large.
-
Use File → Info → Check for Issues → Inspect Document to find hidden content that increases file size.
Other ways to shrink the workbook and remove “ghost” rows
-
Copy only the needed worksheet data to a new workbook:
-
Create a new workbook.
-
Select your data range.
-
Paste into the new workbook.
-
Save the new workbook.
-
-
Save as a different format, such as
.xlsb,for large files with many formulas. -
Remove unused styles and excessive conditional formatting via the Styles pane and Conditional Formatting Rules Manager.
How to verify Excel’s used range after cleaning
-
Press
Ctrl+Endto jump to Excel’s perceived last used cell. -
Confirm that
Ctrl+Endlands at your actual last cell. -
If not, repeat clearing formatting and deleting stray rows/columns, then save and re-open.
Quick checklist you can follow now
-
Back up the file.
-
Clear stray formatting beyond your data.
-
Delete rows below your actual data using the Name Box or keyboard shortcuts.
-
Save, close, and re-open the workbook.
-
Run the VBA macro when multiple sheets need cleaning.
-
Use Document Inspector and consider copy-to-new-workbook or
.xlsbto further shrink the file.
Get Online Tutoring or Questions answered by Experts.
You can post a question for a tutor or set up a tutoring session
Answers · 1
How to sort by highlighted cells in excel
Answers · 1
How to sort excel by column and keep rows together
Answers · 1
How to sort by time in excel
Answers · 1
How to sort alphabetically in excel by last name
Answers · 1