Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 23
Default Find and delete all other rows

Hi all
I am trying to get a Macro to find the word or part of the word in a cell.
All cells that do not have that word should be deleted.
If I use the follwoing it does not work

Set c = .Find("test", LookIn:=xlValues)
If c Is Nothing Then
c.EntireRow.Delete
Else
firstAddress = c.Address
Do
c.Interior.ColorIndex = 6
Set c = .FindNext(c)
Loop While Not c Is Nothing And c.Address < firstAddress
End If
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 35,218
Default Find and delete all other rows

If the range that you're looking through is a single column, you could apply
Data|Filter|autofilter to that column.

Then filter using Custom|Does not contain|test
and delete the visible rows

And then remove the filter.

Murray wrote:

Hi all
I am trying to get a Macro to find the word or part of the word in a cell.
All cells that do not have that word should be deleted.
If I use the follwoing it does not work

Set c = .Find("test", LookIn:=xlValues)
If c Is Nothing Then
c.EntireRow.Delete
Else
firstAddress = c.Address
Do
c.Interior.ColorIndex = 6
Set c = .FindNext(c)
Loop While Not c Is Nothing And c.Address < firstAddress
End If


--

Dave Peterson
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
"Last Cell" to find last row, but can't delete blank rows [email protected] Excel Discussion (Misc queries) 6 January 8th 07 11:50 PM
Find & delete rows with ID's from another sheet. plys Excel Discussion (Misc queries) 1 December 21st 06 04:21 PM
how do i find and delete all empty rows in an excel worksheet AinSF Excel Worksheet Functions 3 September 1st 06 01:38 AM
Macro to find and delete rows! Heather O'Malley Excel Discussion (Misc queries) 2 April 12th 06 01:53 PM
How do I find duplicate rows in a list in Excel, and not delete it Matthew in FL Excel Discussion (Misc queries) 2 June 15th 05 09:11 PM


All times are GMT +1. The time now is 07:36 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"