Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Select a range of rows to delete | Excel Worksheet Functions | |||
select and delete specific rows | Excel Discussion (Misc queries) | |||
Select last n rows and delete? | Excel Programming | |||
select and delete all blank rows | Excel Discussion (Misc queries) | |||
Select certain rows of sheet & delete the rest | Excel Programming |