View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.misc
Shane Devenshire[_2_] Shane Devenshire[_2_] is offline
external usenet poster
 
Posts: 3,346
Default Delete blank rows if more than one

Hi,

Don't really need a macro, but you could record these steps if you wanted:

1. Suppose column A contains data except when you have blank rows, then in
an empty column, lets say D, in D2 enter the formula
=IF(AND(A1="",A2=""),"Y",1)
and copy it down as far as you data goes.
2. Select this range of formulas and press F5, Special, Formulas, and
unchech all except Text, click OK
3. Press Ctrl+- (control minus) and choose Entire row, OK.
4. Clear the formulas from column D

The code to do this runs extremely fast

Sub DeleteExcess()
Dim Bottom As Long
Bottom = [A65536].End(xlUp).Row
Range("D2:D" & Bottom).Select
Selection = "=IF(AND(A2="""",A1=""""),""Y"",1)"
Selection.SpecialCells(xlCellTypeFormulas, 2).EntireRow.Delete
Columns("D:D").ClearContents
End Sub

--
If this helps, please click the Yes button.

Cheers,
Shane Devenshire


"Kjellk" wrote:

I have groups of data divided by blank rows. It is not consistent- sometimes
its one row, sometimes it is more. I want to to keep one blank row between
every group and remove the others.