B
Brian
I have a long text file , some of you may recognise it as a EDI EANCOM 96a
file...
Basically, this file is sent via EDI, but is not imported into our systems.
It is purely used to get sales figures
'LIN+1++9999999932234:EN'QTY+153:1 each line is prefixed with 'LIN+
'LOC+162+9999999949625::9 will give me the location
However the file is one long string, not CSV etc so i have to find a way to
get the imported file to split into rows at each 'LIN+
i have managed to get the text to import, but all in one cell, or split into
the world allocation of cells...
I would like to be able to get the file to dump into a sheet as follows
LOC 9999999949625
LIN STORE QTY 153 QTY 200 QTY 301
1 999999932234 1
2 9999999953277 1
3 9999999956407 1
4 9999999970212 2
Note i also recieve an Inventory File that has a similar format (QTY 200,
301 etc ), so i want to import that at some point to...
Once i get the idea on the best wat to split the file with one QTY i will
look at the bigger one...
As you can see from the text extract below of the file , its not fixed width
of very easy to split....
THIS DONT WORK...
________________________________________
Sub testme2()
Dim FName As String
Dim KeepTheNext As Boolean
Dim FNum As Long
Dim i As Long
Dim sLine As String
FName = "C:\SLSRPT.txt"
FNum = FreeFile
Open FName For Input As FNum
i = 1
KeepTheNext = False
Do While Not EOF(FNum)
Input #FNum, sLine
If InStr(1, sLine, "'LIN+", vbTextCompare) > 0 Then
KeepTheNext = True
Else
If KeepTheNext = True Then
KeepTheNext = False
Cells(i, 1).Value = sLine
' Exit Do
i = i + 1
End If
End If
Loop
End Sub
HELP!!!!!
Thanks for any advice in advance
Brian
________________________________________
SAMPLE OF TEXT....
UNB+UNOA:3+999999990004:14+9999999900001+060205:0508+435+
+SLSRPT'UNH+22+SLSRPT:96A:UN:EAN008'BGM+73E::9+00000014+9'DTM+356:20060129-20060204:718'NAD+FR+9999999900004::9'NAD+SU+9999999900001::9'LOC+162+9999999949625::9'LIN+1++9999999932234:EN'QTY+153:1'LIN+2++9999999953277:EN'QTY+153:-1'LIN+3++9999999956407:EN'QTY+153:1'LIN+4++9999999970212:EN'QTY+153:2'LOC+162+5023949057895::9'LIN+5++21481505:EN'QTY+153:1'LIN+6++9999999923492:EN'QTY+153:-1'LIN+7++9999999929029:EN'QTY+153:2'LIN+8++9999999932418:EN'QTY+153:1'LIN+9++9999999937482:EN'QTY+153:1'LIN+10++9999999949560:EN'QTY+153:-1'LIN+11++9999999953253:EN'QTY+153:2'LIN+12++9999999953888:EN'QTY+153:3'LIN+13++9999999954205:EN'QTY+153:2'LIN+14++9999999954250:EN'QTY+153:1'LIN+15++9999999956407:EN'QTY+153:1'LIN+16++9999999957015:EN'QTY+153:7'LIN+17++9999999957022:EN'QTY+153:2'LIN+18++9999999957473:EN'QTY+153:1'LIN+19++9999999957688:EN'QTY+153:3'LIN+20++9999999957794:EN'QTY+153:2'LIN+21++9999999970496:EN'QTY+153:3'LOC+162+5023949136774::9'LIN+22++21326806:EN'QTY+153:1'LIN+23++9999999923492:EN'QTY+153:2'LIN+24++9999999929029:EN'QTY+153:1'LIN+25++9999999932418:EN'QTY+153:2'LIN+26++9999999953253:EN'QTY+153:1'LIN+27++9999999953260:EN'QTY+153:1'LIN+28++9999999953284:EN'QTY+153:1'LIN+29++9999999953307:EN'QTY+153:1'LIN+30++9999999953338:EN'QTY+153:3'LIN+31++9999999953345:EN'QTY+153:3'LIN+32++9999999953383:EN'QTY+153:-1'LIN+33++9999999953888:EN'QTY+153:7'LIN+34++9999999956391:EN'QTY+153:1'LIN+35++9999999956407:EN'QTY+153:1'LIN+36++9999999957015:EN'QTY+153:2'LIN+37++9999999957022:EN'QTY+153:1'LIN+38++9999999957183:EN'QTY+153:1'LIN+39++9999999957688:EN'QTY+153:2'LIN+40++9999999957695:EN'QTY+153:1'LIN+41++9999999957749:EN'QTY+153:7'LIN+42++9999999957794:EN'QTY+153:10'LIN+43++9999999957879:EN'QTY+153:1'LIN+44++9999999957985:EN'QTY+153:1'LIN+45++9999999958821:EN'QTY+153:-1'LIN+46++9999999961616:EN'QTY+153:3'LIN+47++9999999970199:EN'QTY+153:4'LIN+48++9999999970205:EN'QTY+153:2'LIN+49++9999999970212:EN'QTY+153:5'LIN+50++9999999970649:EN'QTY+153:2'LOC+162+5023949145040::9'LIN+51++5014838064023:EN'QTY+153:3'LIN+52++9999999923492:EN'QTY+153:1'LIN+53++9999999929029:EN'QTY+153:1'LIN+54++9999999932234:EN'QTY+153:3'LIN+55++9999999938557:EN'QTY+153:1'LIN+56++9999999953253:EN'QTY+153:2'LIN+57++9999999953277:EN'QTY+153:2'LIN+58++9999999953284:EN'QTY+153:1'LIN+59++9999999953888:EN'QTY+153:3'LIN+60++9999999954281:EN'QTY+153:1'LIN+61++9999999957015:EN'QTY+153:6'LIN+62++9999999957022:EN'QTY+153:5'LIN+63++9999999957671:EN'QTY+153:2'LIN+64++9999999957794:EN'QTY+153:-1'LIN+65++9999999958821:EN'QTY+153:2'LIN+66++9999999970205:EN'QTY+153:1'LOC+162+5023949182579::9'LIN+67++21326806:EN'QTY+153:1'LIN+68++9999999923492:EN'QTY+153:3'LIN+69++9999999929029:EN'QTY+153:1'LIN+70++9999999929951:EN'QTY+153:-1'LIN+71++9999999932234:EN'QTY+153:2'LIN+72++9999999937482:EN'QTY+153:2'LIN+73++9999999938557:EN'QTY+153:3'LIN+74++9999999943353:EN'QTY+153:1'LIN+75++9999999951419:EN'QTY+153:1'LIN+76++9999999952942:EN'QTY+153:2'LIN+77++9999999953079:EN'QTY+153:6'LIN+78++9999999953147:EN'QTY+153:1'LIN+79++9999999953154:EN'QTY+153:1'LIN+80++9999999953253:EN'QTY+153:1'LIN+81++9999999953260:EN'QTY+153:4'LIN+82++9999999953277:EN'QTY+153:1'LIN+83++9999999953307:EN'QTY+153:1'LIN+84++9999999953338:EN'QTY+153:2'LIN+85++9999999953352:EN'QTY+153:2'LIN+86++9999999953888:EN'QTY+153:-3'LIN+87++9999999954267:EN'QTY+153:3'LIN+88++9999999954328:EN'QTY+153:1'LIN+89++9999999956384:EN'QTY+153:5'LIN+90++9999999956391:EN'QTY+153:9'LIN+91++9999999956407:EN'QTY+153:3'LIN+92++9999999957015:EN'QTY+153:8'LIN+93++9999999957022:EN'QTY+153:4'LIN+94++9999999957251:EN'QTY+153:-2'LIN+95++9999999957473:EN'QTY+153:1'LIN+96++9999999957619:EN'QTY+153:1'LIN+97++9999999957657:EN'QTY+153:-2'LIN+98++9999999957695:EN'QTY+153:1'LIN+99++9999999957732:EN'QTY+153:1'LIN+100++9999999957749:EN'QTY+153:6'LIN+101++9999999957886:EN'QTY+153:2'LIN+102++9999999957985:EN'QTY+153:5'LIN+103++9999999958005:EN'QTY+153:1'LIN+104++9999999958821:EN'QTY+153:8'LIN+105++9999999960657:EN'QTY+153:-1'LIN+106++9999999961616:EN'QTY+153:2'LIN+107++9999999970199:EN'QTY+153:6'LIN+108++9999999970205:EN'QTY+153:5'LIN+109++9999999970557:EN'QTY+153:2'LOC+162+5023949223920::9'LIN+110++5014838064023:EN'QTY+153:3'LIN+111++9999999929029:EN'QTY+153:1'LIN+112++9999999929951:EN'QTY+153:2'LIN+113++9999999929968:EN'QTY+153:-1'LIN+114++9999999938557:EN'QTY+153:1'LIN+115++9999999949560:EN'QTY+153:2'LIN+116++9999999953154:EN'QTY+153:4'LIN+117++9999999953253:EN'QTY+153:3'LIN+118++9999999953284:EN'QTY+153:1'LIN+119++9999999953352:EN'QTY+153:1'LIN+120++9999999953390:EN'QTY+153:1'LIN+121++9999999953888:EN'QTY+153:3'LIN+122++9999999956384:EN'QTY+153:5'LIN+123++9999999956391:EN'QTY+153:14'LIN+124++9999999956407:EN'QTY+153:2'LIN+125++9999999957015:EN'QTY+153:3'LIN+126++9999999957183:EN'QTY+153:3'LIN+127++9999999957251:EN'QTY+153:2'LIN+128++9999999957671:EN'QTY+153:4'LIN+129++9999999957688:EN'QTY+153:2'LIN+130++9999999957701:EN'QTY+153:-1'LIN+131++9999999957794:EN'QTY+153:2'LIN+132++9999999957985:EN'QTY+153:1'LIN+133++9999999961616:EN'QTY+153:7'LIN+134++9999999970199:EN'QTY+153:1'LOC+162+5023949232199::9'LIN+135++9999999923492:EN'QTY+153:1'LIN+136++9999999951419:EN'QTY+153:2'LIN+137++9999999953147:EN'QTY+153:-1'LIN+138++9999999953253:EN'QTY+153:8'LIN+139++9999999953260:EN'QTY+153:3'LIN+140++9999999953277:EN'QTY+153:2'LIN+141++9999999953345:EN'QTY+153:1'LIN+142++9999999953888:EN'QTY+153:2'LIN+143++9999999956384:EN'QTY+153:3'LIN+144++9999999956391:EN'QTY+153:1'LIN+145++9999999956407:EN'QTY+153:1'LIN+146++9999999957015:EN'QTY+153:1'LIN+147++9999999957022:EN'QTY+153:4'LIN+148++9999999957749:EN'QTY+153:3'LIN+149++9999999957909:EN'QTY+153:2'LIN+150++9999999957985:EN'QTY+153:2'LIN+151++9999999970540:EN'QTY+153:2'UNT+1608+22'UNZ+1+435'
file...
Basically, this file is sent via EDI, but is not imported into our systems.
It is purely used to get sales figures
'LIN+1++9999999932234:EN'QTY+153:1 each line is prefixed with 'LIN+
'LOC+162+9999999949625::9 will give me the location
However the file is one long string, not CSV etc so i have to find a way to
get the imported file to split into rows at each 'LIN+
i have managed to get the text to import, but all in one cell, or split into
the world allocation of cells...
I would like to be able to get the file to dump into a sheet as follows
LOC 9999999949625
LIN STORE QTY 153 QTY 200 QTY 301
1 999999932234 1
2 9999999953277 1
3 9999999956407 1
4 9999999970212 2
Note i also recieve an Inventory File that has a similar format (QTY 200,
301 etc ), so i want to import that at some point to...
Once i get the idea on the best wat to split the file with one QTY i will
look at the bigger one...
As you can see from the text extract below of the file , its not fixed width
of very easy to split....
THIS DONT WORK...
________________________________________
Sub testme2()
Dim FName As String
Dim KeepTheNext As Boolean
Dim FNum As Long
Dim i As Long
Dim sLine As String
FName = "C:\SLSRPT.txt"
FNum = FreeFile
Open FName For Input As FNum
i = 1
KeepTheNext = False
Do While Not EOF(FNum)
Input #FNum, sLine
If InStr(1, sLine, "'LIN+", vbTextCompare) > 0 Then
KeepTheNext = True
Else
If KeepTheNext = True Then
KeepTheNext = False
Cells(i, 1).Value = sLine
' Exit Do
i = i + 1
End If
End If
Loop
End Sub
HELP!!!!!
Thanks for any advice in advance
Brian
________________________________________
SAMPLE OF TEXT....
UNB+UNOA:3+999999990004:14+9999999900001+060205:0508+435+
+SLSRPT'UNH+22+SLSRPT:96A:UN:EAN008'BGM+73E::9+00000014+9'DTM+356:20060129-20060204:718'NAD+FR+9999999900004::9'NAD+SU+9999999900001::9'LOC+162+9999999949625::9'LIN+1++9999999932234:EN'QTY+153:1'LIN+2++9999999953277:EN'QTY+153:-1'LIN+3++9999999956407:EN'QTY+153:1'LIN+4++9999999970212:EN'QTY+153:2'LOC+162+5023949057895::9'LIN+5++21481505:EN'QTY+153:1'LIN+6++9999999923492:EN'QTY+153:-1'LIN+7++9999999929029:EN'QTY+153:2'LIN+8++9999999932418:EN'QTY+153:1'LIN+9++9999999937482:EN'QTY+153:1'LIN+10++9999999949560:EN'QTY+153:-1'LIN+11++9999999953253:EN'QTY+153:2'LIN+12++9999999953888:EN'QTY+153:3'LIN+13++9999999954205:EN'QTY+153:2'LIN+14++9999999954250:EN'QTY+153:1'LIN+15++9999999956407:EN'QTY+153:1'LIN+16++9999999957015:EN'QTY+153:7'LIN+17++9999999957022:EN'QTY+153:2'LIN+18++9999999957473:EN'QTY+153:1'LIN+19++9999999957688:EN'QTY+153:3'LIN+20++9999999957794:EN'QTY+153:2'LIN+21++9999999970496:EN'QTY+153:3'LOC+162+5023949136774::9'LIN+22++21326806:EN'QTY+153:1'LIN+23++9999999923492:EN'QTY+153:2'LIN+24++9999999929029:EN'QTY+153:1'LIN+25++9999999932418:EN'QTY+153:2'LIN+26++9999999953253:EN'QTY+153:1'LIN+27++9999999953260:EN'QTY+153:1'LIN+28++9999999953284:EN'QTY+153:1'LIN+29++9999999953307:EN'QTY+153:1'LIN+30++9999999953338:EN'QTY+153:3'LIN+31++9999999953345:EN'QTY+153:3'LIN+32++9999999953383:EN'QTY+153:-1'LIN+33++9999999953888:EN'QTY+153:7'LIN+34++9999999956391:EN'QTY+153:1'LIN+35++9999999956407:EN'QTY+153:1'LIN+36++9999999957015:EN'QTY+153:2'LIN+37++9999999957022:EN'QTY+153:1'LIN+38++9999999957183:EN'QTY+153:1'LIN+39++9999999957688:EN'QTY+153:2'LIN+40++9999999957695:EN'QTY+153:1'LIN+41++9999999957749:EN'QTY+153:7'LIN+42++9999999957794:EN'QTY+153:10'LIN+43++9999999957879:EN'QTY+153:1'LIN+44++9999999957985:EN'QTY+153:1'LIN+45++9999999958821:EN'QTY+153:-1'LIN+46++9999999961616:EN'QTY+153:3'LIN+47++9999999970199:EN'QTY+153:4'LIN+48++9999999970205:EN'QTY+153:2'LIN+49++9999999970212:EN'QTY+153:5'LIN+50++9999999970649:EN'QTY+153:2'LOC+162+5023949145040::9'LIN+51++5014838064023:EN'QTY+153:3'LIN+52++9999999923492:EN'QTY+153:1'LIN+53++9999999929029:EN'QTY+153:1'LIN+54++9999999932234:EN'QTY+153:3'LIN+55++9999999938557:EN'QTY+153:1'LIN+56++9999999953253:EN'QTY+153:2'LIN+57++9999999953277:EN'QTY+153:2'LIN+58++9999999953284:EN'QTY+153:1'LIN+59++9999999953888:EN'QTY+153:3'LIN+60++9999999954281:EN'QTY+153:1'LIN+61++9999999957015:EN'QTY+153:6'LIN+62++9999999957022:EN'QTY+153:5'LIN+63++9999999957671:EN'QTY+153:2'LIN+64++9999999957794:EN'QTY+153:-1'LIN+65++9999999958821:EN'QTY+153:2'LIN+66++9999999970205:EN'QTY+153:1'LOC+162+5023949182579::9'LIN+67++21326806:EN'QTY+153:1'LIN+68++9999999923492:EN'QTY+153:3'LIN+69++9999999929029:EN'QTY+153:1'LIN+70++9999999929951:EN'QTY+153:-1'LIN+71++9999999932234:EN'QTY+153:2'LIN+72++9999999937482:EN'QTY+153:2'LIN+73++9999999938557:EN'QTY+153:3'LIN+74++9999999943353:EN'QTY+153:1'LIN+75++9999999951419:EN'QTY+153:1'LIN+76++9999999952942:EN'QTY+153:2'LIN+77++9999999953079:EN'QTY+153:6'LIN+78++9999999953147:EN'QTY+153:1'LIN+79++9999999953154:EN'QTY+153:1'LIN+80++9999999953253:EN'QTY+153:1'LIN+81++9999999953260:EN'QTY+153:4'LIN+82++9999999953277:EN'QTY+153:1'LIN+83++9999999953307:EN'QTY+153:1'LIN+84++9999999953338:EN'QTY+153:2'LIN+85++9999999953352:EN'QTY+153:2'LIN+86++9999999953888:EN'QTY+153:-3'LIN+87++9999999954267:EN'QTY+153:3'LIN+88++9999999954328:EN'QTY+153:1'LIN+89++9999999956384:EN'QTY+153:5'LIN+90++9999999956391:EN'QTY+153:9'LIN+91++9999999956407:EN'QTY+153:3'LIN+92++9999999957015:EN'QTY+153:8'LIN+93++9999999957022:EN'QTY+153:4'LIN+94++9999999957251:EN'QTY+153:-2'LIN+95++9999999957473:EN'QTY+153:1'LIN+96++9999999957619:EN'QTY+153:1'LIN+97++9999999957657:EN'QTY+153:-2'LIN+98++9999999957695:EN'QTY+153:1'LIN+99++9999999957732:EN'QTY+153:1'LIN+100++9999999957749:EN'QTY+153:6'LIN+101++9999999957886:EN'QTY+153:2'LIN+102++9999999957985:EN'QTY+153:5'LIN+103++9999999958005:EN'QTY+153:1'LIN+104++9999999958821:EN'QTY+153:8'LIN+105++9999999960657:EN'QTY+153:-1'LIN+106++9999999961616:EN'QTY+153:2'LIN+107++9999999970199:EN'QTY+153:6'LIN+108++9999999970205:EN'QTY+153:5'LIN+109++9999999970557:EN'QTY+153:2'LOC+162+5023949223920::9'LIN+110++5014838064023:EN'QTY+153:3'LIN+111++9999999929029:EN'QTY+153:1'LIN+112++9999999929951:EN'QTY+153:2'LIN+113++9999999929968:EN'QTY+153:-1'LIN+114++9999999938557:EN'QTY+153:1'LIN+115++9999999949560:EN'QTY+153:2'LIN+116++9999999953154:EN'QTY+153:4'LIN+117++9999999953253:EN'QTY+153:3'LIN+118++9999999953284:EN'QTY+153:1'LIN+119++9999999953352:EN'QTY+153:1'LIN+120++9999999953390:EN'QTY+153:1'LIN+121++9999999953888:EN'QTY+153:3'LIN+122++9999999956384:EN'QTY+153:5'LIN+123++9999999956391:EN'QTY+153:14'LIN+124++9999999956407:EN'QTY+153:2'LIN+125++9999999957015:EN'QTY+153:3'LIN+126++9999999957183:EN'QTY+153:3'LIN+127++9999999957251:EN'QTY+153:2'LIN+128++9999999957671:EN'QTY+153:4'LIN+129++9999999957688:EN'QTY+153:2'LIN+130++9999999957701:EN'QTY+153:-1'LIN+131++9999999957794:EN'QTY+153:2'LIN+132++9999999957985:EN'QTY+153:1'LIN+133++9999999961616:EN'QTY+153:7'LIN+134++9999999970199:EN'QTY+153:1'LOC+162+5023949232199::9'LIN+135++9999999923492:EN'QTY+153:1'LIN+136++9999999951419:EN'QTY+153:2'LIN+137++9999999953147:EN'QTY+153:-1'LIN+138++9999999953253:EN'QTY+153:8'LIN+139++9999999953260:EN'QTY+153:3'LIN+140++9999999953277:EN'QTY+153:2'LIN+141++9999999953345:EN'QTY+153:1'LIN+142++9999999953888:EN'QTY+153:2'LIN+143++9999999956384:EN'QTY+153:3'LIN+144++9999999956391:EN'QTY+153:1'LIN+145++9999999956407:EN'QTY+153:1'LIN+146++9999999957015:EN'QTY+153:1'LIN+147++9999999957022:EN'QTY+153:4'LIN+148++9999999957749:EN'QTY+153:3'LIN+149++9999999957909:EN'QTY+153:2'LIN+150++9999999957985:EN'QTY+153:2'LIN+151++9999999970540:EN'QTY+153:2'UNT+1608+22'UNZ+1+435'