Deleteing Rows starting with value (text)

C

chesspupil

Using an external UNIX program that quieries a database, I export all
the data found based on my query and export the report as a text file.
THe text file can be up to 1 MB of raw text.

Selecting all text and pasting the data into collum 1 using PASTE
SPECIAL -->(TEXT)

All Data is in Collum A

Each record returned has between 40-50 values each on a seperate row,
only 10 of which I need.

I am looking for a way to find the rows that begin with the unwanted
field, and then delete the entire row.

Otherwise ignore the row.

IE:
AUDFI : (data path loc here)
BILLNUM : 060606
CUTNUM : (0000)
SD : 120012
ED : 121259
CC : 123456789 MATERIAL LISTS AND ITEMS
COMMENT : Multiple lines of text here
with continuing free form data, numbers, operators,

then the next data file would repeat:

ADUFI : (data path loc here)
...
...
...
etc.,

In the above example, I want to delete the rows AUDFI, & CUTNUM and
move the below items up to take the empty rows place. The BILL NUM,
SD,ED, and COMMENT are filed that are always kept (as well as others).
Each record has roughly the same data, each tailored to an event or
object.

The number of rows of data dumped into excel can easily exceed 50000,
about 200 - 1500 records in the report.

After wards, the data is dumped to a text file for easier analysis.

I hope you can help me.

In BASIC my line might look like
5 START
10 if A:$="AUDFI :" then delete row, move below contents up.
20 if A:$="CUTNUM :" then delete row, move below contents up.
30 END

(I think there needs to be a loop since the vaules AUDFI and CUTNUM (as
well as other unwanted fields can occurr 200 - 1500 times each.)
 
T

Tom Ogilvy

Sub ABC()
Do
Set rng = Columns(1).Find("*AUDFI*")
If rng Is Nothing Then Exit Do
rng.EntireRow.Delete
Loop
Do
Set rng = Columns(1).Find("*CUTNUM*")
If rng Is Nothing Then Exit Do
rng.EntireRow.Delete
Loop

End Sub
 

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

Top