Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 193
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,885
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 193
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Macro for deleting rows and serialising the remaing rows Srinivasulu Bhattaram Links and Linking in Excel 1 November 13th 08 08:44 AM
Macro for deleting rows and serialising the remaing rows Srinivasulu Bhattaram Setting up and Configuration of Excel 1 November 12th 08 06:05 PM
Macro for deleting rows and serialising the remaing rows Srinivasulu Bhattaram Excel Worksheet Functions 1 November 12th 08 01:39 PM
Help!! I have problem deleting 2500 rows of filtered rows!!!! shirley_kee Excel Discussion (Misc queries) 1 January 12th 06 03:24 AM
deleting hidden rows so i can print only the rows showing?????? jenn Excel Worksheet Functions 0 October 6th 05 04:05 PM


All times are GMT +1. The time now is 04:58 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"