Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 - |
#5
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Look for cell containing "Initial" then if the next cell after equals "Final" then delete both rows. | Excel Programming | |||
Macro to find a word and copy all rows with this word to diff ws | Excel Programming | |||
macro to intsert a word using the "Find" command to search for a word | Excel Programming | |||
Format fonts (ie, initial cap) in Excel like you can in Word. | Excel Discussion (Misc queries) | |||
Remove middle initial from "first name middle initial" | Excel Discussion (Misc queries) |