View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Ron de Bruin Ron de Bruin is offline
external usenet poster
 
Posts: 11,123
Default remove all blank or empty rows

Try this for the activesheet
It will loop through all rows with data

Sub Example1()
Dim Lrow As Long
Dim CalcMode As Long
With Application
CalcMode = .Calculation
.Calculation = xlCalculationManual
.ScreenUpdating = False
End With

With ActiveSheet
.DisplayPageBreaks = False
For Lrow = .UsedRange.Rows.Count To 1 Step -1
If Application.CountA(.Rows(Lrow)) = 0 Then .Rows(Lrow).Delete
'This will delete the row if the whole row is empty (all columns)
End If
Next
End With
With Application
.ScreenUpdating = True
.Calculation = CalcMode
End With
End Sub


I have add some example code on a webpage
http://www.rondebruin.nl/tips.htm

Post back if you need help

--
Regards Ron de Bruin
(Win XP Pro SP-1 XL2000-2003)
www.rondebruin.nl



" wrote in message
...
I'm new to VBA and I'm working on a project and leaning it
as I go. I'm at that point where I think I need a loop
that will loop through the rows and remove all blank or
empty rows. The worksheet will have a varying number of
rows and my have 1 to 4 blank or empty rows in a row (or
together)

Thanks to all who read this. Thanks to all who replay