LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 25
Default macro to select cells containing specific text and delete all cells but these

I am attempting to sort data containing specific characters and delete
all rows but the ones that meet the critera. Such as search for "LW"
and get all LWLI, LWOS, LWSC, etc.

I have a macro working currently that will select one of the above and
delete all the rest...but I need to make this a bit more robust to keep
all LW's

Dim rng As Range, cell As Range, del As Range
Set rng = Intersect(Range("A:A"), ActiveSheet.UsedRange)
For Each cell In rng
If (cell.Value) < "LWLI" Then
If del Is Nothing Then
Set del = cell
Else: Set del = Union(del, cell)
End If
End If
Next cell
On Error Resume Next
del.EntireRow.Delete '

If I need to go about this from the back side and manually list all vs
a wild card type entry than I will, but I still need some help and
making a multiple selection criteria. When I try this now...It is
seeing the search as exclusive and deleting all data.

 
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
Need macro to delete all text cells in an Excel range GVT Excel Worksheet Functions 2 February 26th 06 12:25 PM
How do I pause a macro to select specific cells lee Excel Worksheet Functions 1 April 2nd 05 02:11 PM
Delete specific cells contents in a row with some locked cells in the same row trussman Excel Programming 2 March 1st 05 06:12 PM
Excel Macro Query - Search for specific text in cells of a column Mcneilius Excel Programming 2 August 29th 04 05:12 PM
Macro to delete rows with text cells zsalleh Excel Programming 8 August 27th 04 12:22 AM


All times are GMT +1. The time now is 04:41 PM.

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

About Us

"It's about Microsoft Excel"