View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Ron de Bruin Ron de Bruin is offline
external usenet poster
 
Posts: 11,123
Default Slow Delete Blank Rows Macro

Warning

See this page
http://www.rondebruin.nl/delete.htm#Specialcells

--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm


"JP" wrote in message ...
What about

Range("P2:P50000").SpecialCells(xlCellTypeBlanks). EntireRow.Delete

?

HTH,
JP

On Mar 29, 8:40 pm, Monk wrote:
I am using the code below to delete blank rows from up to 50,000 rows of
data. The data can be between 20,000 and 50,000 rows. It works fine however
it takes about 10 mins to complete. Any suggestions on improved code that
could complete the task quicker?

Sub Delete_Rows_Empty()
Application.Calculation = xlManual
Application.ScreenUpdating = False
Dim Rng As Range, ix As Long
Dim csht As Long
Set Rng = Range("p2:p50000")
For ix = Rng.Count To 1 Step -1
If Trim(Application.Substitute(Rng.Item(ix).Text, _
Chr(160), Chr(32))) = "" Then
Rng.Item(ix).EntireRow.Delete
End If
Next
done:
Application.ScreenUpdating = True
Application.Calculation = xlAutomatic
End Sub