Delete rows using a macro

  • Thread starter Thread starter Sasikiran
  • Start date Start date
S

Sasikiran

Hello,

I need help with a macro that will delete certain rows in a spreadsheet.
The rows that need to be deleted are never in the same place, or the same
number of rows. The thing that the rows I want to delete all have in common
a specific word say "YES" in the same column. But they are never in the same
place everytime.

Please suggest me on this.
 
Here is a typical example. The macro deletes any rows with "YES" in column B:

Sub YESMan()
n = Cells(Rows.Count, "B").End(xlUp).Row
For i = n To 1 Step -1
If Cells(i, "B").Value = "YES" Then
Cells(i, "B").EntireRow.Delete
End If
Next
End Sub
 
Thanks a ton :)

Gary''s Student said:
Here is a typical example. The macro deletes any rows with "YES" in column B:

Sub YESMan()
n = Cells(Rows.Count, "B").End(xlUp).Row
For i = n To 1 Step -1
If Cells(i, "B").Value = "YES" Then
Cells(i, "B").EntireRow.Delete
End If
Next
End Sub
 
Back
Top