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

Why are there 1,048,576 rows in Excel?
The Excel team increased the size of the grid in 2007. There are 2^20 rows and 2^14 columns for a total of 17 billion cells.
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,223,275
Messages
6,171,123
Members
452,381
Latest member
Nova88

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