Delete Row if Col. H contains either"Current Period" or"Year to Da

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi,

I need to delete all rows if they contain either "Current Period" or"Year to
Date" in Column H. The other Rows should move up accordingly. How do I change
the code below to include "Year to Date" ???
Next i
For i = 2 To n
If Cells(i, 8) = "Current Period" Then
Cells(i + 1, 8).Resize(1, 5).Cut Cells(i, 8)
Rows(i + 1).Delete
End If
Next i

Thanks,

Manir
 
manfareed,

If ((Cells(i, 8) = "Current Period") or (Cells(i, 8) = "Year to Date")) Then
 
Manir,

Presuming the rest of your code works already, change :-

If Cells(i, 8) = "Current Period" Then

to: -

If Cells(i, 8) = "Current Period" OR Cells(i, 8) = "Year to Date" Then


hth,

Tim
 
Sub rdel()
n = Cells(Rows.Count, "H").End(xlUp).Row
For i = n To 1 Step -1
With Cells(i, "H")
If .Value = "Current Period" Or .Value = "Year to Date" Then
.EntireRow.Delete
End If
End With
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

Back
Top