Delete rows by criteria

Deverti

Board Regular
Joined
Sep 5, 2020
Messages
56
Office Version
  1. 365
Platform
  1. Windows
Im using this simple code as a part to clean a software export.

The additional criteria i dont know how to implement would be:
delete row if cell in column A is the only cell in said row that holds any value

VBA Code:
Sub DelEmptyRows()
lRow = Range("A" & Rows.Count).End(xlUp).Row
    Set rngA = Range("A10:A" & lRow)

    With ActiveSheet
        rngA.SpecialCells(xlCellTypeBlanks).EntireRow.Delete
    End With

End Sub
 

Some videos you may like

Excel Facts

Does the VLOOKUP table have to be sorted?
No! when you are using an exact match, the VLOOKUP table can be in any order. Best-selling items at the top is actually the best.

JoeMo

MrExcel MVP
Joined
May 26, 2009
Messages
17,326
Office Version
  1. 365
  2. 2010
Platform
  1. Windows
Untested, but see if this works on a copy of your worksheet.
VBA Code:
Sub DelEmptyRows()
Application.ScreenUpdating = False
lRow = Range("A" & Rows.Count).End(xlUp).Row
    Set rngA = Range("A10:A" & lRow)
    For i = 1 To rngA.Rows.Count
        If Application.CountA(rngA(i)) = Application.CountA(rngA(i).EntireRow) _
            Then rngA(i).Value = ""
    Next i
    On Error Resume Next
    rngA.SpecialCells(xlCellTypeBlanks).EntireRow.Delete
    On Error GoTo 0
Application.ScreenUpdating = True
End Sub
 
Solution

Deverti

Board Regular
Joined
Sep 5, 2020
Messages
56
Office Version
  1. 365
Platform
  1. Windows
that was quick and it runs perfectly.
thanks joe
 

Watch MrExcel Video

Forum statistics

Threads
1,114,542
Messages
5,548,634
Members
410,861
Latest member
Victor96
Top