Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Deleting rows not containing one of 3 values
I need to delete all rows in a worksheet which don't contain one of three
values. I haven't been able to figure out how to do this. |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Deleting rows not containing one of 3 values
Dim lastRow as Long, i as Long
Dim value1, value2, value3 Value1 = "A" Value2 = 6 Value3 = "*Dog*" lastrow = Cells(rows.count,1).End(xlup).Row for i = lastrow to 2 step -1 if Application.Countif(rows(i),value1) + Application.Countif(rows(i),value2) + Application.Countif(rows(i),value3) = 0 then rows(i).Delete end if Next -- Regards, Tom Ogilvy "Byron" wrote in message ... I need to delete all rows in a worksheet which don't contain one of three values. I haven't been able to figure out how to do this. |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Deleting rows not containing one of 3 values
Works great, just what I was after. Thanks much
Byron "Tom Ogilvy" wrote: Dim lastRow as Long, i as Long Dim value1, value2, value3 Value1 = "A" Value2 = 6 Value3 = "*Dog*" lastrow = Cells(rows.count,1).End(xlup).Row for i = lastrow to 2 step -1 if Application.Countif(rows(i),value1) + Application.Countif(rows(i),value2) + Application.Countif(rows(i),value3) = 0 then rows(i).Delete end if Next -- Regards, Tom Ogilvy "Byron" wrote in message ... I need to delete all rows in a worksheet which don't contain one of three values. I haven't been able to figure out how to do this. |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Deleting rows based on column values | New Users to Excel | |||
Deleting rows based on values in a a cell in the row | New Users to Excel | |||
Deleting rows with specific values | Excel Discussion (Misc queries) | |||
Deleting Rows with Same Values | Excel Programming | |||
Deleting Rows beased on Values | Excel Programming |