Deleting rows preceding

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

HI,
I have the following program that deletes the entire row when it finds the
characters "Inst" in Column A. Besides deleting just that row, I would also
like to be able to delete the three rows above it. Would I be able to change
this program and do it?
Thanks for your help.

_________________
Public Sub DeleteRows()

Dim RowNdx As Long
Dim LastRow As Long
LastRow = Cells(Rows.Count, "A").End(xlUp).Row
For RowNdx = LastRow To 1 Step -1
If Cells(RowNdx, "A").Value = "Inst" Then
Rows(RowNdx).Delete
End If
Next RowNdx

End Sub
_________________
 
Hi
not tested but try:
Public Sub DeleteRows()

Dim RowNdx As Long
Dim LastRow As Long
LastRow = Cells(Rows.Count, "A").End(xlUp).Row
For RowNdx = LastRow-4 To 1 Step -1
If Cells(RowNdx+4, "A").Value = "Inst" Then
cells(rowndx,1).resize(4,1).entirerow.Delete
End If
Next RowNdx

End Sub
 
Hi Frank,
It doesnt do anything.
I dont necessarily have to use this same program. If you have another
program that might work, would you please share it.
Thanks for your prompt reply.

Robert
 

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

Back
Top