ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Delete Row if Col. H contains either"Current Period" or"Year to Da (https://www.excelbanter.com/excel-programming/398540-delete-row-if-col-h-contains-either-current-period-year-da.html)

manfareed

Delete Row if Col. H contains either"Current Period" or"Year to Da
 
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

JRForm

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

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


"manfareed" wrote:

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


Tim

Delete Row if Col. H contains either"Current Period" or"Year to Da
 
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


"manfareed" wrote in message
...
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




Gary''s Student

Delete Row if Col. H contains either"Current Period" or"Year to Da
 
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

--
Gary''s Student - gsnu200748


"manfareed" wrote:

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

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

Thanks to all. All solutions work.

Regards,

Manir

"manfareed" wrote:

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



All times are GMT +1. The time now is 05:16 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com