Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Excel / New Users / November 2007

Tip: Looking for answers? Try searching our database.

Select and hide between two rows

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
SteveG - 10 Nov 2007 08:14 GMT
I have a long text file from which I want to extract blocks of data.

As a text import all the text starts in Column A.  There are about
1000 lines in each file.

I want to:

1) Search for a word "apple" within each string/row then
2) Search for another word "bacon" in another string/row then ...
3) Select and hide the rows from row "apple" to row "bacon"
4) Repeat for the next occurance "apple" to "bacon". There are 29
occurances in each file.

Once I am sure that I have the correct selection I would then delete
the hidden rows.

Any ideas?
rshewade - 10 Nov 2007 09:35 GMT
For this you need to write a macro. If you know VBA Coding
It can do all the things, the you require.

> I have a long text file from which I want to extract blocks of data.
>
[quoted text clipped - 13 lines]
>
> Any ideas?
Bob Phillips - 10 Nov 2007 11:41 GMT
Sub Clearout()
Dim LastRow As Long
Dim mpCell As Range
Dim mpStart As Long
Dim mpEnd As Long

   LastRow = Range("A" & Rows.Count).End(xlUp).Row
   Do
       Set mpCell = Nothing
       Set mpCell = Columns(1).Find("apple", LookIn:=xlValues)
       If Not mpCell Is Nothing Then
           mpStart = mpCell.Row
           Set mpCell = Nothing
           Set mpCell = Columns(1).Find("bacon", LookIn:=xlValues)
           If Not mpCell Is Nothing Then
               mpEnd = mpCell.Row
               Rows(mpStart & ":" & mpEnd).Delete
           End If
       End If
   Loop Until mpCell Is Nothing
End Sub

Signature

HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)

>I have a long text file from which I want to extract blocks of data.
>
[quoted text clipped - 13 lines]
>
> Any ideas?
SteveG - 13 Nov 2007 07:39 GMT
Works as advertised!

Thanks

Rate this thread:






 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.