Most Efficient Way to Delete Blank Rows?

Tuta

Board Regular
Joined
Nov 6, 2008
Messages
85
Office Version
  1. 365
Platform
  1. Windows
All,

I have a macro that currently selects blank cells and deletes the entire row. This file is around 9,000 rows of data in which 1,800 or so are being deleted.

Code:
Range("A1").Select
ActiveCell.Offset(2, 2).Range("A1:A" & FinalRow - 1).Select
Selection.SpecialCells(xlCellTypeBlanks).Select
Selection.EntireRow.Delete
It is currently bogging down Excel 2010/64bit on a computer that has 6gb ram. The macro turns off screenupdating before it gets to this point.

Is this the most efficient code to delete rows or is a loop better?

Thanks!
 

Excel Facts

Control Word Wrap
Press Alt+Enter to move to a new row in a cell. Lets you control where the words wrap.
That should be fast - do you have lots of formulas in this sheet? Would be worth turning off calculation first as well eg:

Code:
Dim xlCalc As xlCalculation

With Application
  xlCalc = .Calculation
  .Calculation = xlCalculationManual
End With

'delete code


Application.Calculation = xlCalc
 
Upvote 0
Exactly four formulas in the entire workbook.

---
I wanted to watch it as it ran through the macro, so I turned the screenupdating on and it worked fine. Stepped through everything.

I then ran through it with screenupdating off and the macro worked fine.

Maybe excel needed to warm up?
 
Upvote 0

Forum statistics

Threads
1,224,600
Messages
6,179,835
Members
452,947
Latest member
Gerry_F

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top