Tough Macro Question

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Here is my problem. I have a text file that I'm importing into Excel. I
what to find a starting point (a given row) in the single column data and
tell the Macro to delete all text above that row. Then I want to find an
ending point (a given row) and tell the Macro to delete all text below that
point.

My problem is that the starting and ending row may not be the same point
every time.

I had originally created a macro for this process, but it has predefined
starting and ending rows and will therefore delete valid data that is needed.
 
Turn on the macro recorder then use Edit=>Find and search for the term that
will mark the start of your data that you want to retain. Repeat for the
term that will mark the end of your data that you want to retain. Turn off
the macro recorder. Now you can use this to identify where to start and
where to end (modify the recorded code)

Dim rng as Range
Dim rng1 as Range
set rng = columns(1).find("Start", . . . )
set rng1 = columns(1).find("End", . . . )

range(rng1.offset(1,0),"A65536").Entirerow.Delete
range("a1",rng.offset(-1,0)).Entirerow.delete

--
Regards,
Tom Ogilvy

Chris said:
Here is my problem. I have a text file that I'm importing into Excel. I
what to find a starting point (a given row) in the single column data and
tell the Macro to delete all text above that row. Then I want to find an
ending point (a given row) and tell the Macro to delete all text below that
point.

My problem is that the starting and ending row may not be the same point
every time.

I had originally created a macro for this process, but it has predefined
starting and ending rows and will therefore delete valid data that is
needed.
 
What are the rules to determine the start and end rows.

--

HTH

RP
(remove nothere from the email address if mailing direct)


Chris said:
Here is my problem. I have a text file that I'm importing into Excel. I
what to find a starting point (a given row) in the single column data and
tell the Macro to delete all text above that row. Then I want to find an
ending point (a given row) and tell the Macro to delete all text below that
point.

My problem is that the starting and ending row may not be the same point
every time.

I had originally created a macro for this process, but it has predefined
starting and ending rows and will therefore delete valid data that is
needed.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top