Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 34
Default Remove all rows which do Not contain a particular word

I need a program which will remove from a largs WorkSheet all rows if the
word "High' is not present in the row.
Thanks
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Remove all rows which do Not contain a particular word


You need to be more specific, would high be an entry in any cell in
row or just say column A. or the first 5 columns. The longer the range
the longer the macro will take to run.
Also would it be in a text string or the entire cell
eg how high can you jump
or just "high"

and if it was the later was for example "highly regarded" would it b
retained as well?

Regards

Da

--
Da
-----------------------------------------------------------------------
Dav's Profile: http://www.excelforum.com/member.php...fo&userid=2710
View this thread: http://www.excelforum.com/showthread.php?threadid=56097

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 34
Default Remove all rows which do Not contain a particular word

Thanks Dav for your interest.

The word "high" will be in column A. It will be a discrete word, but may
have other words in the same cell

Regards


"Dav" wrote:


You need to be more specific, would high be an entry in any cell in a
row or just say column A. or the first 5 columns. The longer the ranges
the longer the macro will take to run.
Also would it be in a text string or the entire cell
eg how high can you jump
or just "high"

and if it was the later was for example "highly regarded" would it be
retained as well?

Regards

Dav


--
Dav
------------------------------------------------------------------------
Dav's Profile: http://www.excelforum.com/member.php...o&userid=27107
View this thread: http://www.excelforum.com/showthread...hreadid=560979


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Remove all rows which do Not contain a particular word

You could use data|Filter to show the cells that contain "high".

Then delete those visible rows.

Record a macro when you do it manually if you want the code.

Kanga 85 wrote:

Thanks Dav for your interest.

The word "high" will be in column A. It will be a discrete word, but may
have other words in the same cell

Regards

"Dav" wrote:


You need to be more specific, would high be an entry in any cell in a
row or just say column A. or the first 5 columns. The longer the ranges
the longer the macro will take to run.
Also would it be in a text string or the entire cell
eg how high can you jump
or just "high"

and if it was the later was for example "highly regarded" would it be
retained as well?

Regards

Dav


--
Dav
------------------------------------------------------------------------
Dav's Profile: http://www.excelforum.com/member.php...o&userid=27107
View this thread: http://www.excelforum.com/showthread...hreadid=560979



--

Dave Peterson
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Remove all rows which do Not contain a particular word


To use Dave's Idea the following should work, much simpler than what
was thinking of as I do not really use filter, perhaps I should loo
into them a bit more! To use filters, the top row of your sheet has t
be a heading row, so the data starts in row 2

Sub Macro4()
'
' Macro4 Macro

'
Range("A1").Select
Selection.AutoFilter
Selection.AutoFilter Field:=1, Criteria1:="<*high*"
Operator:=xlAnd
Range("A2:a65533").Select
Selection.EntireRow.Delete
Selection.AutoFilter
Range("A1").Select
End Sub

Regards

Da

--
Da
-----------------------------------------------------------------------
Dav's Profile: http://www.excelforum.com/member.php...fo&userid=2710
View this thread: http://www.excelforum.com/showthread.php?threadid=56097



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 34
Default Remove all rows which do Not contain a particular word

Thanks Dav and Dave

"Dav" wrote:


To use Dave's Idea the following should work, much simpler than what I
was thinking of as I do not really use filter, perhaps I should look
into them a bit more! To use filters, the top row of your sheet has to
be a heading row, so the data starts in row 2

Sub Macro4()
'
' Macro4 Macro

'
Range("A1").Select
Selection.AutoFilter
Selection.AutoFilter Field:=1, Criteria1:="<*high*",
Operator:=xlAnd
Range("A2:a65533").Select
Selection.EntireRow.Delete
Selection.AutoFilter
Range("A1").Select
End Sub

Regards

Dav


--
Dav
------------------------------------------------------------------------
Dav's Profile: http://www.excelforum.com/member.php...o&userid=27107
View this thread: http://www.excelforum.com/showthread...hreadid=560979


  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 34
Default Remove all rows which do Not contain a particular word

Dav,
When I used your Sub Macro4() below, it remove all my data below row 1;
which is definately not what I wanted.
I modified your macro to:

Range("A2:A65533").Select
Selection.AutoFilter Field:=1, Criteria1:="<*high*", Operator:=xlAnd
Selection.EntireRow.Delete
Range("A1").Select

which works well for all data below row 2, but which always deletes row 2
whether it meets the criteria or not. This means that if I subsequently run
the same macro, I then just loose row 2 each time.
Any suggestions?
Thanks,


"Dav" wrote:


To use Dave's Idea the following should work, much simpler than what I
was thinking of as I do not really use filter, perhaps I should look
into them a bit more! To use filters, the top row of your sheet has to
be a heading row, so the data starts in row 2

Sub Macro4()
'
' Macro4 Macro

'
Range("A1").Select
Selection.AutoFilter
Selection.AutoFilter Field:=1, Criteria1:="<*high*",
Operator:=xlAnd
Range("A2:a65533").Select
Selection.EntireRow.Delete
Selection.AutoFilter
Range("A1").Select
End Sub

Regards

Dav


--
Dav
------------------------------------------------------------------------
Dav's Profile: http://www.excelforum.com/member.php...o&userid=27107
View this thread: http://www.excelforum.com/showthread...hreadid=560979


  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 13
Default Remove all rows which do Not contain a particular word

Hi All,

May be you need :

Sub DellRows()

For r = 1 To 100 ' 100 is end of rows you want
If Cells(r, 1).Value = "High" Then del = del & ",A" & r
Next r
If del < "" Then Range(Mid(del, 2, Len(del))).EntireRow.Delete

End Sub


Kanga 85 menuliskan:
Thanks Dav for your interest.

The word "high" will be in column A. It will be a discrete word, but may
have other words in the same cell

Regards


"Dav" wrote:


You need to be more specific, would high be an entry in any cell in a
row or just say column A. or the first 5 columns. The longer the ranges
the longer the macro will take to run.
Also would it be in a text string or the entire cell
eg how high can you jump
or just "high"

and if it was the later was for example "highly regarded" would it be
retained as well?

Regards

Dav


--
Dav
------------------------------------------------------------------------
Dav's Profile: http://www.excelforum.com/member.php...o&userid=27107
View this thread: http://www.excelforum.com/showthread...hreadid=560979



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
remove last word dk New Users to Excel 9 January 11th 08 06:09 PM
remove rows in one sheet from similar rows in another G[_2_] Excel Worksheet Functions 0 November 12th 07 03:57 PM
how to add word to the front of every word in all rows automatica. Jasmine Excel Discussion (Misc queries) 8 October 10th 05 05:28 PM
Remove complete row containing a single word Kanga 85 Excel Worksheet Functions 4 February 23rd 05 02:23 AM
How to remove a word from dictionary? robmirabile Excel Discussion (Misc queries) 7 December 8th 04 06:39 PM


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