HELP - I need to adjust code!!!!

J

jriendeau5

Help!!!

I need to adjust the below code to not only delete the row with foun
value, but also 10 rows above it. How can I change the code to d
this?

Thanks!!

Jenny

*********************************************************

Sub delete_rows()
Dim lastrow As Long
Dim row_index As Long
Application.ScreenUpdating = False
lastrow = ActiveSheet.Cells(Rows.Count, 1).End(xlUp).Row
For row_index = lastrow - 1 To 1 Step -1

If IsError(Cells(row_index, 1).Value) Then
' do nothing
ElseIf InStr(Cells(row_index, 1).Value, " ***** CONTINUED"
Then
Rows(row_index).Delete
End If

Next
Application.ScreenUpdating = True
End Sub
********************************************************
 
H

Harald Staff

Hi Jenny

One way:

For i = 1 To 10
Rows(row_index - 9).Delete
Next

HTH. Best wishes Harald
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top