Delete row if cell in col b is blank

C

claytorm

Hi

I have a large sheet and need a macro to delete any row which does no
have a value in column B. So, if B32 was blank, the whole of row 3
would be deleted. Can anyone come up with a simple macro to do this?

Thanks,

Berti
 
G

Gary''s Student

Try:

Sub rowremover()
Dim i As Long
For i = 65536 To 1 Step -1
If IsEmpty(Cells(i, 2)) Then
Rows(i).Select
Selection.Delete Shift:=xlUp
End If
Next
End Sub

Without VBA, just sort on column B and discard the blanks.
 
D

Don Guillett

why use all rows and why select?

For i = cells(rows.count,"b").end(xlup).row To 2 Step -1
If IsEmpty(Cells(i, 2)) Then Rows(i).Delete
Next
 
R

Ron de Bruin

Hi claytorm

If they are really blank and no more then 8192 separate areas ?

With ActiveSheet
On Error Resume Next
.Columns("B").SpecialCells(xlCellTypeBlanks).EntireRow.Delete
On Error GoTo 0
End With

Or other ways
http://www.rondebruin.nl/delete.htm
 
Top