Delete lines with a blank cell
Hi F
I have tested both If .Value statements and they work as they should
depending on your requirement.
Sub Remove_Blanks()
Dim Firstrow As Long
Dim Lastrow As Long
Dim Lrow As Long
With Application
CalcMode = .Calculation
.Calculation = xlCalculationManual
End With
With Sheets("Addresses").Select
Firstrow = .UsedRange.Cells(2).Row
Lastrow = .UsedRange.Rows(.UsedRange.Rows.Count).Row
For Lrow = Lastrow To Firstrow Step -1
With .Cells(Lrow, "B")
If Not IsError(.Value) Then
'use this if you want to retain blank cell(s) in Column
B with formulas
If .Value = "" Then
..Resize(Lastrow).SpecialCells(xlCellTypeBlanks).E ntireRow.Delete
'use this if you want to delete the row(s) regardless
If .Value = "" Then .EntireRow.Delete
End If
End With
Next Lrow
End With
With Application
CalcMode = .Calculation
.Calculation = xlAutomatic
End With
End Sub
HTH
Mick.
|