A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Excel » Worksheet Functions
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

del certain rows based on word search



 
 
Thread Tools Display Modes
  #1  
Old June 16th, 2009, 09:30 PM posted to microsoft.public.excel.worksheet.functions
Robert
external usenet poster
 
Posts: 717
Default del certain rows based on word search

Hello,
I import about 50 pages of data from another program that leaves page
headers which consist of 10 rows of junk. In between these rows of headers,
there is aprox. 10 to 12 rows of good data, not always the same number of
rows. I would like to end up with just the data and delete the junk rows. The
one common identifier (for search purposes) I see is the company name in
column E of the top of the header (the 1st row of junk). How would I go about
automatically searching out and deleting the row that includes the company
name, as well as the 9 tows beneath it?. This header exists about 50 times,
so I need something that can search through and delete all of the headers.

thanks in advance for any help,
Robert
  #2  
Old June 16th, 2009, 10:48 PM posted to microsoft.public.excel.worksheet.functions
Gord Dibben
external usenet poster
 
Posts: 20,252
Default del certain rows based on word search

Sub DeleteRows()
FindString = "company name" 'adjust to company name
Set b = Range("E:E").Find(what:=FindString, lookat:=xlWhole)
While Not (b Is Nothing)
b.Resize(10).EntireRow.delete
Set b = Range("E:E").Find(what:=FindString, lookat:=xlWhole)
Wend
End Sub


Gord Dibben MS Excel MVP

On Tue, 16 Jun 2009 13:30:02 -0700, Robert
wrote:

Hello,
I import about 50 pages of data from another program that leaves page
headers which consist of 10 rows of junk. In between these rows of headers,
there is aprox. 10 to 12 rows of good data, not always the same number of
rows. I would like to end up with just the data and delete the junk rows. The
one common identifier (for search purposes) I see is the company name in
column E of the top of the header (the 1st row of junk). How would I go about
automatically searching out and deleting the row that includes the company
name, as well as the 9 tows beneath it?. This header exists about 50 times,
so I need something that can search through and delete all of the headers.

thanks in advance for any help,
Robert


  #3  
Old June 17th, 2009, 01:46 AM posted to microsoft.public.excel.worksheet.functions
Robert
external usenet poster
 
Posts: 717
Default del certain rows based on word search

Sweet! This works great. Thanks Gord!
Robert

"Gord Dibben" wrote:

Sub DeleteRows()
FindString = "company name" 'adjust to company name
Set b = Range("E:E").Find(what:=FindString, lookat:=xlWhole)
While Not (b Is Nothing)
b.Resize(10).EntireRow.delete
Set b = Range("E:E").Find(what:=FindString, lookat:=xlWhole)
Wend
End Sub


Gord Dibben MS Excel MVP

On Tue, 16 Jun 2009 13:30:02 -0700, Robert
wrote:

Hello,
I import about 50 pages of data from another program that leaves page
headers which consist of 10 rows of junk. In between these rows of headers,
there is aprox. 10 to 12 rows of good data, not always the same number of
rows. I would like to end up with just the data and delete the junk rows. The
one common identifier (for search purposes) I see is the company name in
column E of the top of the header (the 1st row of junk). How would I go about
automatically searching out and deleting the row that includes the company
name, as well as the 9 tows beneath it?. This header exists about 50 times,
so I need something that can search through and delete all of the headers.

thanks in advance for any help,
Robert



 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 09:35 PM.


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