Hi,
I wonder if somebody could help me. My VB knowledge is limited and I need some help with a VB script an ex member of staff has written.
The script looks at a text file and pulls the infomation into Excel. As far as I can tell the scripts looks for === as the beginning point and then pulls the folling information until it gets to the end of line.
Example:-
=== 22601331 NC MANORD 1624.0 812.00 748.29 0.00 0.00 0.00 0.00 1560.29 0.00 060130 22601622 NC MANORD 1150.0 575.00 530.25 0.00 0.00 0.00 0.00 1105.25 0.00 060116
However, the format of the text file has changed and instead of the info being on 1 line it's now on several lines
Example:-
===
22601331 NC MANORD 1624.0 812.00 748.29 0.00 0.00 0.00 0.00 1560.29 0.00 060130
22601622 NC MANORD 1150.0 575.00 530.25 0.00 0.00 0.00 0.00 1105.25 0.00 060116
So the script is falling over as it isn't finding anything after the start point. I need a way of change the scripts from looknig for 1 continues line to looking for several lines.
The code that is currently being used is:-
Sorry for the stupidly long post but if anybody could shed any light on this I would be more then grateful.
Thanks in advance.
I wonder if somebody could help me. My VB knowledge is limited and I need some help with a VB script an ex member of staff has written.
The script looks at a text file and pulls the infomation into Excel. As far as I can tell the scripts looks for === as the beginning point and then pulls the folling information until it gets to the end of line.
Example:-
=== 22601331 NC MANORD 1624.0 812.00 748.29 0.00 0.00 0.00 0.00 1560.29 0.00 060130 22601622 NC MANORD 1150.0 575.00 530.25 0.00 0.00 0.00 0.00 1105.25 0.00 060116
However, the format of the text file has changed and instead of the info being on 1 line it's now on several lines
Example:-
===
22601331 NC MANORD 1624.0 812.00 748.29 0.00 0.00 0.00 0.00 1560.29 0.00 060130
22601622 NC MANORD 1150.0 575.00 530.25 0.00 0.00 0.00 0.00 1105.25 0.00 060116
So the script is falling over as it isn't finding anything after the start point. I need a way of change the scripts from looknig for 1 continues line to looking for several lines.
The code that is currently being used is:-
Code:
Dim Airline, AWBNum As String Dim ProcDone, Cont, UseEst Dim Charges(100) Dim Descs(100), ChgDesc(100) As String Dim Estimates(100), Actuals(100) Dim I, J As Integer crow = 2 chgcode = Sheets("Charges").Range("A" & crow) While chgcode <> "" Descs(chgcode) = Sheets("Charges").Range("B" & crow) crow = crow + 1 chgcode = Sheets("Charges").Range("A" & crow) Wend numdesc = 0 For I = 1 To 99 desc = Descs(I) If desc <> "" Then found = False For J = 1 To numdesc If desc = ChgDesc(J) Then found = True: J = 99 Next J If Not found Then numdesc = numdesc + 1 ChgDesc(numdesc) = desc End If End If Next I ChgDesc(numdesc + 1) = "Other" ProcDone = False infile = Range("E7") UseEst = Range("AA1") On Error GoTo NoInFile Open infile For Input As #1 On Error GoTo 0 Workbooks.Add bookname = ActiveWorkbook.Name While Not EOF(1) fstart = 0 While fstart = 0 And Not EOF(1) Line Input #1, inrec Cont = False recno = recno + 1 fstart = InStr(inrec, "IATA CARGO ACCOUNTS SETTLEMENT SYSTEM") If fstart = 0 Then stpos = InStr(inrec, "=== ") If stpos <> 0 Then Cont = True fstart = 1 Else If Left(inrec, 7) = "CARRIED" Then While Not EOF(1) And Left(inrec, 7) <> "BROUGHT" Line Input #1, inrec recno = recno + 1 Wend If Not EOF(1) Then Line Input #1, inrec recno = recno + 1 Cont = True stpos = -3 fstart = 1 End If End If End If
Thanks in advance.
Comment