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. |
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. |
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. |
All times are GMT +1. The time now is 11:32 PM. |
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com