ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   find word initial then final...... (https://www.excelbanter.com/excel-programming/398308-find-word-initial-then-final.html)

[email protected][_2_]

find word initial then final......
 
Can someone please help with this small request.

I need a macro to find the word "intial" in column A and if the word
in the cell immediately below that contains the word "final" then it
should delete both the two rows.

The have to be in the order of "Intial" then "Final" as this would
mean there has been no activity in between the two.

I hope someone can help.

Thanks in advance,

Andrea


David

find word initial then final......
 
Try this, by no means the most efficient way but it seems to work. I
recommend you test it on some backed-up files first as I am not going
to be held liable if it does something it shouldn't! Change the range
"A1:A1000" to however many rows you need.

Sub find()
RowNum = 0
For Each cell In Range("A1:A1000")
RowNum = RowNum + 1
If cell.Value = "Initial" Then
If cell.Offset(1, 0).Value = "Final" Then
Rows(RowNum).EntireRow.Delete
Rows(RowNum + 1).EntireRow.Delete
End If
End If
Next
End Sub


joel

find word initial then final......
 
Sub test()

Lastrow = Cells(Rows.Count, "A").End(xlUp).Row

For RowCount = Lastrow To 1 Step -1
If (Range("A" & RowCount) = "Initial") And _
Range("A" & RowCount + 1) = "Final" Then

Rows(RowCount & ":" & (RowCount + 1)).Delete
End If
Next RowCount


End Sub


" wrote:

Can someone please help with this small request.

I need a macro to find the word "intial" in column A and if the word
in the cell immediately below that contains the word "final" then it
should delete both the two rows.

The have to be in the order of "Intial" then "Final" as this would
mean there has been no activity in between the two.

I hope someone can help.

Thanks in advance,

Andrea



[email protected][_2_]

find word initial then final......
 
Thank you so much

This worked perfectly.

Andrea

On Sep 28, 11:50 am, Joel wrote:
Sub test()

Lastrow = Cells(Rows.Count, "A").End(xlUp).Row

For RowCount = Lastrow To 1 Step -1
If (Range("A" & RowCount) = "Initial") And _
Range("A" & RowCount + 1) = "Final" Then

Rows(RowCount & ":" & (RowCount + 1)).Delete
End If
Next RowCount

End Sub



" wrote:
Can someone please help with this small request.


I need a macro to find the word "intial" in column A and if the word
in the cell immediately below that contains the word "final" then it
should delete both the two rows.


The have to be in the order of "Intial" then "Final" as this would
mean there has been no activity in between the two.


I hope someone can help.


Thanks in advance,


Andrea- Hide quoted text -


- Show quoted text -




Dave Peterson

find word initial then final......
 
Check your other post.



" wrote:

Can someone please help with this small request.

I need a macro to find the word "intial" in column A and if the word
in the cell immediately below that contains the word "final" then it
should delete both the two rows.

The have to be in the order of "Intial" then "Final" as this would
mean there has been no activity in between the two.

I hope someone can help.

Thanks in advance,

Andrea


--

Dave Peterson


All times are GMT +1. The time now is 11:25 AM.

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