View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
Byron[_5_] Byron[_5_] is offline
external usenet poster
 
Posts: 18
Default 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.