Created
February 28, 2018 21:12
-
-
Save jamesxv7/3e10c661fb8769316af7b7a92fe7d2c7 to your computer and use it in GitHub Desktop.
Delete blank rows in Excel using VBA
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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