Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,670
Default select and delete certain rows

Does anyone have code for selecting a group of rows, checking one column for
the highest/lowest value of the group, deleting the other rows -- then moving
to the next group?

Just trying to save some time. Thanks!
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default select and delete certain rows

Sub ABC()
Dim rng As Range, rng1 As Range
Dim lastrow As Long, i As Long
Dim dMax As Double, icol As Long
Dim j as Long
' set column to find max value
icol = 3
lastrow = Cells(Rows.Count, 1).End(xlUp).Row
For i = lastrow To 10 Step -10
Set rng = Cells(i, 1)
Set rng = rng.Offset(-9, 0).Resize(10, 1).EntireRow
Set rng1 = Intersect(rng.EntireRow, Columns(icol))
dMax = Application.Max(rng1)
For j = i To i - 9 Step -1
If Cells(j, icol) < dMax Then
rows(j).Delete
End If
Next j
Next i
End Sub

--
Regards,
Tom Ogilvy


"Eric" wrote:

Does anyone have code for selecting a group of rows, checking one column for
the highest/lowest value of the group, deleting the other rows -- then moving
to the next group?

Just trying to save some time. Thanks!

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
Select a range of rows to delete Donna[_3_] Excel Worksheet Functions 2 January 26th 10 07:32 PM
select and delete specific rows Paulg Excel Discussion (Misc queries) 1 August 22nd 06 04:12 PM
Select last n rows and delete? JD Excel Programming 4 February 2nd 06 12:02 AM
select and delete all blank rows Bill from UniqueAuction.com Excel Discussion (Misc queries) 1 October 11th 05 09:06 PM
Select certain rows of sheet & delete the rest Steve Wylie Excel Programming 2 January 9th 04 07:16 PM


All times are GMT +1. The time now is 08:48 AM.

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"