How to Delete rows with blank or specific value in a Macro ?

  • Thread starter Thread starter Glenn
  • Start date Start date
G

Glenn

I would like to know if there's a way, within a macro, to delete rows within
a specific range if the first cell in the row is either empty or has a
specific value, such as 'False'.
 
This should do it:

Sub test()
Dim TargetRange As Range
Set TargetRange = Range("A10:D15") ' Change to suit desired range
TargetCol = TargetRange.Column
FirstRow = TargetRange.Row
LastRow = TargetRange.Rows.Count + FirstRow - 1
For r = LastRow To FirstRow Step -1
If Cells(r, TargetCol).Value = "" Or _
Cells(r, TargetCol).Value = "False" Then
Rows(r).Delete
End If
Next
End Sub
 
Back
Top