Delete all rows between two key words

leeksleeks

Board Regular
Joined
Oct 31, 2013
Messages
96
Hi,

I am having trouble deleting the rows between two key words I have on my worksheet. I can select them but can't work out how to delete all the rows in between and not just the row that the first word appears on. So far I have the following code to select the rows between the key words:
Code:
Sub SelectKeyWordRanges()

    With ActiveSheet
    .Range(.Cells.Find("Scoring history"), .Rows.Find("Match stats")).Select
    
    End With

To summarise if "Scoring history was in cell A:10 and "Match stats" was in A:20, I would want to delete all rows (including the data in columns B,C,D etc) in between.

I thank you in advance!
 

Excel Facts

Whats the difference between CONCAT and CONCATENATE?
The newer CONCAT function can reference a range of cells. =CONCATENATE(A1,A2,A3,A4,A5) becomes =CONCAT(A1:A5)
Hello,

probalby not the only solution

Code:
Sub SelectKeyWordRanges()
    With ActiveSheet
        MY_START = .Cells.Find("Scoring history").Row + 1
        MY_END = .Cells.Find("Match stats").Row - 1
        .Rows(MY_START & ":" & MY_END).Delete
    End With
End Sub
 
Upvote 0

Forum statistics

Threads
1,221,470
Messages
6,160,029
Members
451,611
Latest member
PattiButche

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top