OzGrid

How to create automatic removal of empty rows

< Back to Search results

 Category: [Excel]  Demo Available 

How to create automatic removal of empty rows

 

Requirement:

 

https://www.ozgrid.com/forum/forum/help-forums/excel-vba-macros/148040-automatic-removal-of-empty-rows

 

The user wants to create code to automatically remove empty rows.

 

Solution:

 

If you need to remove completely blank rows ...

Code:
Sub RemoveBlankRows()
' Author  Andy Pope     
    Dim lngRow As Long 
     
    Application.ScreenUpdating = False 
    Application.Calculation = xlCalculationManual 
     
    lngRow = ActiveSheet.UsedRange.Rows(ActiveSheet.UsedRange.Rows.Count).Row 
     
    Do While lngRow > 0 
        If Application.WorksheetFunction.CountA(ActiveSheet.Rows(lngRow)) = 0 Then 
            ActiveSheet.Rows(lngRow).Delete 
        End If 
        lngRow = lngRow - 1 
    Loop 
     
    Application.ScreenUpdating = True 
    Application.Calculation = xlCalculationAutomatic 
     
End Sub
 

 

Obtained from the OzGrid Help Forum.

Solution provided by Carim.

 

See also: Index to Excel VBA Code and Index to Excel Freebies and Lesson 1 - Excel Fundamentals and Index to how to… providing a range of solutions and Index to new resources and reference sheets

 

See also:

How to remove text after last comma, only if cell has 3 commas
How to use VBA to copy column based on heading
How to count and delete duplicate entries over multiple columns
How to use VBA to change zero value to blank value based on criteria in other columns

 

Click here to visit our Free 24/7 Excel/VBA Help Forum where there are thousands of posts you can get information from, or you can join the Forum and post your own questions.


Gallery



stars (0 Reviews)