ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Tough Macro Question (https://www.excelbanter.com/excel-programming/324233-tough-macro-question.html)

Chris

Tough Macro Question
 
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.

Tom Ogilvy

Tough Macro Question
 
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" wrote in message
...
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.



Bob Phillips[_6_]

Tough Macro Question
 
What are the rules to determine the start and end rows.

--

HTH

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


"Chris" wrote in message
...
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.




All times are GMT +1. The time now is 01:11 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com