Skip to content

Instantly share code, notes, and snippets.

@jamesxv7
Created February 28, 2018 21:12
Show Gist options
  • Save jamesxv7/3e10c661fb8769316af7b7a92fe7d2c7 to your computer and use it in GitHub Desktop.
Save jamesxv7/3e10c661fb8769316af7b7a92fe7d2c7 to your computer and use it in GitHub Desktop.
Delete blank rows in Excel using VBA
Sub DeleteBlankRows()
Dim Rng As Range
Dim WorkRng As Range
On Error Resume Next
xTitleId = "Title"
Set WorkRng = Application.Selection
Set WorkRng = Application.InputBox("Range", xTitleId, WorkRng.Address, Type:=8)
xRows = WorkRng.Rows.Count
Application.ScreenUpdating = False
For i = xRows To 1 Step -1
If Application.WorksheetFunction.CountA(WorkRng.Rows(i)) = 0 Then
WorkRng.Rows(i).EntireRow.Delete XlDeleteShiftDirection.xlShiftUp
End If
Next
Application.ScreenUpdating = True
End Sub
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment