1

Is there an easy way to tell Excel to delete a row if a certain cell in an intersecting column is blank? Would this require VBA?

As a reference point, I found the following VBA code:

Dim FoundCell As Range
    Application.ScreenUpdating = False
    Set FoundCell = Range("B:B").Find(what:="")
    Do Until FoundCell Is Nothing
        FoundCell.EntireRow.Delete
        Set FoundCell = Range("B:B").FindNext
    Loop

but for some reason it crashes when I try to run it.

Community
  • 1
  • 1
114
  • 876
  • 3
  • 25
  • 51

2 Answers2

0

If you wish to delete all rows in which the value in column B is blank, then try:

Sub KleanB()
    Dim B As Range, rDel As Range, r As Range, N As Long
    N = Cells(Rows.Count, "B").End(xlUp).Row
    Set B = Range("B1:B" & N)
    B.Cells.SpecialCells(xlCellTypeBlanks).EntireRow.Delete
End Sub
Gary's Student
  • 95,722
  • 10
  • 59
  • 99
0

For a non-VBA solution:

Select the column where the blanks may appear. Press F5 (GoTo), click Special and select Blanks. Click OK. Only blank cells will be select. Right click on one of the blank cells and click Delete Row.

Excel Developers
  • 2,785
  • 2
  • 21
  • 35