I have a text file that needs a bunch of "junk" removed from it before I import it into my d/base...
There are 3 types of lines that I need -
1. Any line that starts with "N#*"
2. Any line that starts with "Acc*"
3. Any line that the 1st character starts at position 13
The text file is generated from our mainframe system and has all the header info, page numbers, employee info, etc..
The core data that I need is in a fixed width format, just need to clean all the other stuff out. The biggest problem I'm having is printin' out the lines that don't have a character (blank spaces) until the 13th position from the left.
Below is an example of what I'm working with...
Any suggestion or examples would be the huckleberry..!!
Thanks in advance..!!
jcw5107
Sub deletestuff()
Dim strLine 'As Variant
Dim strType As Variant
Dim strImportFile As String
strImportFile = "D:\UPSDATA\ASSIGNEDTASKS.txt"
Open "D:\UPSDATA\ASSIGNED TASKS SUMMARY.txt" For Input As #1
Open strImportFile For Output As #2
Do Until EOF(1)
Line Input #1, strLine
If Left(strLine, 4) Like "N###*" _
Or Left(strLine, 3) Like "Acc*" _
Or left(strLine, 13) <> " " Then
strType = strLine
Print #2, strType
End If
Loop
Close #1
Close #2
End Sub
There are 3 types of lines that I need -
1. Any line that starts with "N#*"
2. Any line that starts with "Acc*"
3. Any line that the 1st character starts at position 13
The text file is generated from our mainframe system and has all the header info, page numbers, employee info, etc..
The core data that I need is in a fixed width format, just need to clean all the other stuff out. The biggest problem I'm having is printin' out the lines that don't have a character (blank spaces) until the 13th position from the left.
Below is an example of what I'm working with...
Any suggestion or examples would be the huckleberry..!!
Thanks in advance..!!
jcw5107
Sub deletestuff()
Dim strLine 'As Variant
Dim strType As Variant
Dim strImportFile As String
strImportFile = "D:\UPSDATA\ASSIGNEDTASKS.txt"
Open "D:\UPSDATA\ASSIGNED TASKS SUMMARY.txt" For Input As #1
Open strImportFile For Output As #2
Do Until EOF(1)
Line Input #1, strLine
If Left(strLine, 4) Like "N###*" _
Or Left(strLine, 3) Like "Acc*" _
Or left(strLine, 13) <> " " Then
strType = strLine
Print #2, strType
End If
Loop
Close #1
Close #2
End Sub