Home |
Search |
Today's Posts |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
On Oct 8, 10:51*am, "J.W. Aldridge"
wrote: Code works, but keeps deleting the headers in row 1. How to avoid/fix please? Sub Delete_ROUTES_ColE() Application.ScreenUpdating = False * * * * Dim Firstrow As Long * * * * Dim Lastrow As Long * * * * Dim Lrow As Long * * * * With ActiveSheet * * * * 'Set the first and last row to loop through * * * * Firstrow = .UsedRange.Cells(2).Row 'The 1 represents the RowIndex * * * * Lastrow = .UsedRange.Rows(.UsedRange.Rows.Count).Row * * * * 'Loop from Lastrow to Firstrow (bottom to top) * * * * For Lrow = Lastrow To Firstrow Step -1 * * * * 'Check the values in the D column * * * * With .Cells(Lrow, "E") * * * * * * If .Value < "APPLES" And .Value < "GRAPES" And ..Value < "PLUMS" And .Value < "DATES" And .Value < "PEARS" Then .EntireRow.Delete * * * * End With * * * * Next Lrow * * End With Application.ScreenUpdating = True End Sub I would have done it differently but instead of cells(2), use cells(2,1) or range("a2") |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
lookup using column headers and row headers | Excel Discussion (Misc queries) | |||
Hide Column Headers but not row (Headers) | Excel Programming | |||
Controlling Row Inserts and Deletes Via Code | Excel Programming | |||
More help on setting print headers via code | Excel Programming | |||
Modifying Code that deletes a Row | Excel Programming |