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

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'.
 
P

Per Jessen

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top