OzGrid

How to delete rows with no value

< Back to Search results

 Category: [Excel]  Demo Available 

How to delete rows with no value

 

Requirement:

 

Code:
Sub RemoveLinebreaks()
Dim Rw As Range

If WorksheetFunction.CountA(Selection) = 0 Then

   MsgBox "No data found", vbOKOnly, "OzGrid.com"

   Exit Sub

End If

    With Application

        .Calculation = xlCalculationManual

        .ScreenUpdating = False



    Selection.SpecialCells(xlCellTypeBlanks).Select



        For Each Rw In Selection.Rows

            If WorksheetFunction.CountA(Selection.EntireRow) = 0 Then

                Selection.EntireRow.Delete

            End If

        Next Rw



        .Calculation = xlCalculationAutomatic

        .ScreenUpdating = True

    End With

End Sub

 

https://www.ozgrid.com/forum/forum/help-forums/excel-vba-macros/1206089-deleting-rows-with-no-value

 

Solution:

 

I assume you want the empty cells from A11:J45 deleted.
See attached.

Code:
Sub Maybe()
    Dim lr As Long
    Dim i As Long
    Application.ScreenUpdating = False
    lr = Cells(Rows.Count, 1).End(xlUp).Row
    For i = lr To 12 Step -1
        If Range("A" & i).Offset(, 1).HasFormula = True And Range("A" & i).Offset(, 1).Value = 0 Or _
           Range("A" & i).Offset(, 1).HasFormula = True And Range("A" & i).Offset(, 1).Value = "" Or _
           Range("A" & i).Offset(, 1).Value = "" Then Range("A" & i).Resize(, 10).Delete Shift:=xlUp
    Next i
    Application.ScreenUpdating = True
End Sub

 

Obtained from the OzGrid Help Forum.

Solution provided by jolivanes.

 

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 loop each row if there is data after green colour cell then delete
How to use VBA to delete rows based on multiple conditions
How to use Excel VBA to delete rows in a column based on a range of cells in another column
How to count and delete duplicate entries over multiple 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)