Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 18
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default 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   Report Post  
Posted to microsoft.public.excel.programming
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.




Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Deleting rows based on column values Dazed and Confused[_2_] New Users to Excel 3 February 6th 09 10:47 PM
Deleting rows based on values in a a cell in the row Martin New Users to Excel 1 January 25th 09 11:46 AM
Deleting rows with specific values whatzzup Excel Discussion (Misc queries) 1 July 6th 06 10:35 AM
Deleting Rows with Same Values ...Patrick[_5_] Excel Programming 0 September 8th 04 09:06 PM
Deleting Rows beased on Values Todd Huttenstine[_2_] Excel Programming 6 December 2nd 03 05:40 AM


All times are GMT +1. The time now is 02:10 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"