Macro to remove rows?

  • Thread starter Thread starter Bad at VBA
  • Start date Start date
B

Bad at VBA

Hi,

I receive thousands of rows of data from an extract that comes from a
database. The data extract automatically generates page headers that
need to be removed, and I would love to automate this process.

The headers do have a pattern to them, but I'm not clever enough to
figure out a good way to use that to write a macro.

The first row of the header starts with hyphens
-------------------------------
Then there's a variable number of rows of header data to delete
followed by another row of hyphens
-------------------------------
Then 2 additional rows that must be deleted.

The number of rows between the headers is not a constant, which makes
no sense to me, but there you go.

Any help would be greatly appreciated!
 
Bad,

Can you post a sample of the first few characters from a typical
header section and a few data rows?

You may be able to use brute force and just sort the records and
delete or omit the garbage - if the data you want to keep is
numerical.

Patrick
 
Hi Patrick,

Actually, the data I want to keep is text. The header rows are similar
to:

-----------------------------------------------------------
Report
Grand Count: 4139
User xxxx
Date 20090529
data 20090401 to 20090430
more data
more data
sometimes more data sometimes less
Some info
---------------------------------
|Heading names
|--------------------------------
This is text I would want to keep here
More text to keep

I hope that is helpful!
 
Oh, and just to be clear, there will be somewhere between 50 and 60
rows of data that I want to keep, then a repeat of the header. The
headers are consistent in a single download, but the number of rows
they take up varies from month to month.
 
Hi,

You probably won't get a response because your sample data is unclear.
Please try to post a sample of the data set not a stylized approximation.

For example

------
Header1
Header2
Header3
------
Age FName LName
34 xxx yyyy
54 aaa bn
-------
Header4
Header5
Header6
---------
and so on...

It is not at all clear from your sample which lines are headers and which
not.
 
I can do that! Any row that has hyphens or says Header I need to
remove.

-----------------------------------------------------------
Header
Header
Header
Header (The number of header rows in this section varies)
Header (But it is always set off by hyphen rows)
Header
Header
Header
Header
---------------------------------
Header
|--------------------------------
Age FName LName
43 xxx xxx
22 xxx xxx
(usually about 50 - 60 rows of real data before the next header
sequence starts)
-----------------------------------------------------------
Header
Header
Header
Header (The number of header rows in this section varies)
Header (But it is always set off by hyphen rows)
Header
Header
Header
Header
---------------------------------
Header
|--------------------------------
Age FName LName
43 xxx xxx
22 xxx xxx
 
Back
Top