Hi,
This works for me
Private Sub Extract_Records()
Open ThisWorkbook.Path & Application.PathSeparator & "Invoice.txt" For Input
As #1
r = 1
Do While Not EOF(1)
Input #1, Data$
If UCase(Left(Data$, 5)) < "TOTAL" And Val(Mid(Data$, 5, 1)) 0 Then
r = r + 1
Cells(r, 1).Value = Data
End If
Loop
Close #1
End Sub
--
Mike
When competing hypotheses are otherwise equal, adopt the hypothesis that
introduces the fewest assumptions while still sufficiently answering the
question.
"Spreadsheet Solutions" wrote:
Dear members;
I'm stuck with the following chalange.
I must read some (not all) records from a textfile into a workbook.
But......
The Excel version is 2003 (can and may not be 2007) and the textfile
contains over 250.000 records !!
The fields from the textfile are seperated by semi-colons and I only need
those records where the 5th field exceeds 0.
The textfile is not fixed-width, so I can't fix this position in a record
(but it is the position I need to find).
What method should I use to extract those records using VBA.
Is it possible to alter this module ?
Private Sub Extract_Records()
Open ThisWorkbook.Path & Application.PathSeparator & "Invoice.txt" For
Input As #1
r = 1
Do While Not EOF(1)
Line Input #1, Data
'Do not import a record that begins with Total
If Not Left(Data, 5) = "TOTAL" Then '---- I think I should change
this line of code, but How ? It must find the 5th field 0
'Import record
r = r + 1
Cells(r, 1).Value = Data
End If
Loop
Close #1
End Sub
----
I hope that this is clear enough !!
--
Regards;
Mark Rosenkrantz
--
Spreadsheet Solutions
Uithoorn
Netherlands
--
E:
W: www.spreadsheetsolutions.nl
--
.