Hello,
Try this:
Sub Foo()
Dim lngLastRow As Long
Dim rngToCheck As Range, rngToDelete As Range
Application.ScreenUpdating = False
With Sheet1
'find the last row in the range
lngLastRow = GetLastRow(.Range("A:G"))
If lngLastRow > 1 Then
'we want to check the used range in columns A to G
Set rngToCheck = .Range(.Cells(1, "a"), .Cells(lngLastRow, "g"))
'if there are no blank cells then there will be an error
On Error Resume Next
Set rngToDelete = rngToCheck.SpecialCells(xlCellTypeBlanks)
On Error GoTo 0
'allow for overlapping ranges
If Not rngToDelete Is Nothing Then _
Application.Intersect(.Range("A:A"), rngToDelete.EntireRow).EntireRow.Delete
End If
End With
Application.ScreenUpdating = True
End Sub
Public Function GetLastRow(ByVal rngToCheck As Range) As Long
Dim rngLast As Range
Set rngLast = rngToCheck.Find(what:="*", searchorder:=xlByRows, searchdirection:=xlPrevious)
If rngLast Is Nothing Then
GetLastRow = rngToCheck.Row
Else
GetLastRow = rngLast.Row
End If
End Function
Change Sheet1 to the codename of the sheet you want to do this on.
Bookmarks