Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 53
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 39
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 53
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Look for cell containing "Initial" then if the next cell after equals "Final" then delete both rows. [email protected][_2_] Excel Programming 3 September 28th 07 01:45 PM
Macro to find a word and copy all rows with this word to diff ws Chas Excel Programming 3 April 27th 07 11:16 PM
macro to intsert a word using the "Find" command to search for a word Stuart[_3_] Excel Programming 1 November 29th 06 05:13 AM
Format fonts (ie, initial cap) in Excel like you can in Word. gojackets1979 Excel Discussion (Misc queries) 1 October 14th 05 12:20 AM
Remove middle initial from "first name middle initial" Justin F. Excel Discussion (Misc queries) 15 September 26th 05 06:13 PM


All times are GMT +1. The time now is 01:12 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"