Home |
Search |
Today's Posts |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
"GregR" wrote in news:1129824703.024847.179940
@g47g2000cwa.googlegroups.com: I have a table with many rows. I want to delete all rows that do not contain "*computers and phones*" in column (6). Rows 1 and 2 are header rows. How do I proceed? TIA Greg Greg, I would do this manually by: Turning on Autofilter (Data - Filter - AutoFilter) Apply a custom filter on column 6 (does not contain) Select the visible cells in column 6 that I want to remove Edit - Delete Row Here's a procedure that does the same thing: Sub DeleteRows() Dim rng As Range Set rng = Sheet1.Range("F2:F6") Sheet1.AutoFilterMode = False rng.AutoFilter Field:=1, Criteria1:="<*computers and phones*" Range(rng.Offset(1, 0), rng.Offset(rng.Rows.Count, 0)) _ .SpecialCells(xlCellTypeVisible).EntireRow.Delete Sheet1.AutoFilterMode = False Set rng = Nothing End Sub Note that I started in the second row so that the headings are not lost. Don't know if this is faster than Tom's loop. HTH, RP |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Macro to delete sheets and saves remaining file does not properly delete module | Excel Programming | |||
Macro to delete sheets and saves remaining file does not properly delete module | Excel Programming | |||
Macro to delete sheets and saves remaining file does not properly delete module | Excel Programming | |||
Macro to delete sheets and saves remaining file does not properly delete module | Excel Programming | |||
Delete every 3rd row, then delete rows 2-7, move info f/every 2nd row up one to the end and delete the row below | Excel Programming |