Question : How to Create a Macro to remove blanks from Excel 2007 Worksheet

Hi all
I have a workshet with approximately 100k rows in excel2007.  I need to remove 4 blank rows, 1 line of data and another blank row after it.  Could someone please show me how to create a macro to clean up my worksheet?

Please see attached image.  Note: I want to delete lines 8239 through 8244.

Thanks

Answer : How to Create a Macro to remove blanks from Excel 2007 Worksheet

Paul, please try this:

1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
Sub BajanPaul()
Dim lastRow As Long, i As Long
Application.ScreenUpdating = False
lastRow = ActiveSheet.UsedRange.Rows.Count
For i = lastRow To 6 Step -1
    If Not IsNull(Rows(i).Text) And IsNull(Rows(i - 1).Text) And Not IsNull(Rows(i - 2).Text) And _
        Not IsNull(Rows(i - 3).Text) And Not IsNull(Rows(i - 4).Text) And Not IsNull(Rows(i - 5).Text) Then
                        Range(Rows(i - 5), Rows(i)).Delete
            i = i - 5
    End If
Next
Application.ScreenUpdating = True
End Sub
Random Solutions  
 
programming4us programming4us