VBA problem importing and auditing Unix reports

  • Thread starter Thread starter acarril
  • Start date Start date
A

acarril

I have been tasked to analyze data from several unix reports (downloade
to C:\). I just recently had my first exposure to VBA but am trying m
best. I wish to import these reports into Excel. I would need t
"clean up" (remove empty rows,sort the data, and remove certai
unwanted text such as mulitple headers). when all is done, i woul
need to be left with a worksheet for each report and a consolidate
master with combined information.
I already have the code for deleting emptly rows. Attached is
sample(4 pages of many) of the downloaded report. Any help would b
greatly appreciated

Attachment filename: openpo.txt
Download attachment: http://www.excelforum.com/attachment.php?postid=55993
 
This gets you down to the details:

You can add back your desired heading and use Excel to build any subtotals
you need.

Sub AAOpenReport()
' Change the next to lines to refer to your report file.
ChDir "C:\Data6"
Workbooks.OpenText Filename:="C:\Data6\openpo.txt", Origin:=xlWindows, _
StartRow:=1, DataType:=xlFixedWidth, _
FieldInfo:=Array(Array(0, 1), Array(8, 1), _
Array(11, 1), Array(16, 1), _
Array(33, 1), Array(44, 1), _
Array(65, 1), Array(70, 1), _
Array(81, 1), Array(91, 1), _
Array(100, 1), Array(110, 1), _
Array(122, 1))
Set rng = Columns(1).SpecialCells(xlBlanks)
rng.EntireRow.Delete
With Columns(1)
.Replace What:="RTROPNPO", Replacement:="=Na()", _
LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False
.Replace What:="R*", Replacement:="=Na()", _
LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False

.Replace What:="DIST*", Replacement:="=Na()", _
LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False
.Replace What:="---*", Replacement:="=Na()", _
LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False
.Replace What:="PO", Replacement:="=Na()", _
LookAt:=xlWhole, _
SearchOrder:=xlByRows, MatchCase:=False

End With
Columns(2).Replace What:="At", _
Replacement:="=Na()", LookAt:=xlWhole, _
SearchOrder:=xlByRows, MatchCase:=True
Columns("A:B").SpecialCells(xlFormulas, _
xlErrors).EntireRow.Delete
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

Back
Top