Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Deleting rows preceding
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 _________________ |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Deleting rows preceding
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 "Robert" wrote: 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 _________________ |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Deleting rows preceding
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 "Frank Kabel" wrote: 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 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Macro for deleting rows and serialising the remaing rows | Links and Linking in Excel | |||
Macro for deleting rows and serialising the remaing rows | Setting up and Configuration of Excel | |||
Macro for deleting rows and serialising the remaing rows | Excel Worksheet Functions | |||
Help!! I have problem deleting 2500 rows of filtered rows!!!! | Excel Discussion (Misc queries) | |||
deleting hidden rows so i can print only the rows showing?????? | Excel Worksheet Functions |