Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Thanks ever so much Tom, your help was greatly appreciated.
I tied all this up it now works excellent! It has saved me many hours every Monday to produce a readable report for one user!!! Like I said, anyone who needs to import EDI EANCOM data into excel will find these examples extremely useful!!!! Thanks again Tom!!! Brian INVRPT: (if you wish to parse the text for SLSRPT files see the earlier example on previous post) -------------------------------------------------------- On the worksheet i have... Sub GETINVRPT() Dim FName As String Dim FNum As Long Dim l As String Dim l1 As Variant Dim s As String Dim sChr As String Dim rng1 As Range, rng As Range Dim cell As Range, iloc As Long Columns("A:M").ClearContents Columns(6).NumberFormat = _ "0000000000000" FName = "C:\INVRPT.txt" FNum = FreeFile Open FName For Input As FNum Line Input #FNum, s s = Replace(s, Chr(9), "") l = s l = Replace(l, "LIN+", "LIN+,") l = Replace(l, "QTY+", "LIN+,,") l = Replace(l, "::9", "") l = Replace(l, "++", ",'") l = Replace(l, "'", "") l = Replace(l, ":EN", "") l = Replace(l, "LOC+", ",") l = Replace(l, "17:", "QTY 17,") l = Replace(l, "83:", "QTY 83,") l = Replace(l, "198:", "QTY 198,") l = Replace(l, "14+", "14,") l = Replace(l, "18+", "18,") l1 = Split(l, "LIN+") l1 = TransArr(l1) Cells(1, 1).Resize(UBound(l1, 1) - _ LBound(l1, 1) + 1).Value = l1 Close #FNum Rows(1).Delete Columns(1).TextToColumns _ Destination:=Range("A1"), _ DataType:=xlDelimited, _ TextQualifier:=xlDoubleQuote, _ ConsecutiveDelimiter:=False, _ Tab:=True, _ Semicolon:=False, _ Comma:=True, _ Space:=False, _ Other:=False, _ FieldInfo:=Array( _ Array(1, 1), _ Array(2, 1), _ Array(3, 1), _ Array(4, 1), _ Array(5, 1), _ Array(6, 1)) Set rng2 = Range(Cells(1, 2), _ Cells(Rows.Count, 2).End(xlUp)) For Each cell In rng2.SpecialCells(xlConstants) cell.Offset(0, -1).Delete Shift:=xlShiftToLeft Next Set cell = Cells(Rows.Count, "F").End(xlUp) lastrow = cell.Row If InStr(1, cell, "UNT", vbTextCompare) 0 Then cell = Left(cell, InStr(1, cell, "UNT", vbTextCompare) - 1) End If Set rng2 = Range(Cells(1, 2), _ Cells(Rows.Count, 2).End(xlUp)) For Each cell In rng2 cell.Value = "'" & cell.Value Next Columns(6).NumberFormat = _ "0000000000000" Columns("C:D").Cut Columns("G").Insert Columns("C").Copy Columns("A") Columns("C").Delete Columns("E").NumberFormat = "General" Set cell = Cells(Rows.Count, "C").End(xlUp) lastrow = cell.Row For i = 2 To lastrow Set cell1 = Cells(i, "B") If Len(Trim(cell1)) < 3 Then cell1.Value = "'" & cell1.Offset(-1, 0).Value End If Next Set rng = Nothing OldEan = "" For i = 2 To lastrow If Cells(i, 3) < "" Then If Cells(i, 3) < OldEan Then OldEan = Cells(i, 3) firstrow = i Cells(firstrow, 8).Value = 0 End If If Cells(i, "D") = "QTY 17" Then col = 8 ElseIf Cells(i, "D") = "QTY 198" Then col = 6 ElseIf Cells(i, "D") = "QTY 83" Then col = 7 End If If Trim(Cells(i, "E")) < "" Then Cells(firstrow, col) = Cells(i, "E") + Cells(firstrow, col) End If End If Next Set rng = Columns(8).SpecialCells(xlBlanks) rng.EntireRow.Delete Rows(1).Insert Columns("D:E").Delete Columns("A:A").Delete Range("A1:E1").Value = Array( _ "EAN", "LOC", "QTY198", "QTY83", "QTY17") End Sub Public Function TransArr(v As Variant) Dim v1() As Variant ReDim v1(LBound(v) To UBound(v), 0 To 0) For i = LBound(v) To UBound(v) v1(i, 0) = v(i) Next TransArr = v1 End Function ---------------------------------------------------------------------------- Module is: Sub Macro1() ' ' Macro1 Macro ' Macro recorded 2/18/2006 by Thomas Ogilvy ' ' Columns("A:A").Select Selection.TextToColumns Destination:=Range("A1"), DataType:=xlDelimited, _ TextQualifier:=xlDoubleQuote, ConsecutiveDelimiter:=False, Tab:=True, _ Semicolon:=False, Comma:=True, Space:=False, Other:=False, FieldInfo _ :=Array(Array(1, 1), Array(2, 1), Array(3, 1), Array(4, 1), Array(5, 1), Array(6, 1)) Columns("F:F").EntireColumn.AutoFit End Sub -------------------------------------------------------------------------------------------- "Tom Ogilvy" wrote in message ... Brian, Hard to know where to jump in. If you want to send me a copy of the source file, I will see what I can discover on my own while you do your thing. You have the advantage of knowing what some of this stuff means. To me, it is just a line of characters and numbers. |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Importing Long String - String Manipulation (INVRPT) (EDI EANCOM 96a) | Excel Programming | |||
Importing Long String - String Manipulation (EDI EANCOM 96a) | Excel Programming | |||
From String to Long | Excel Programming | |||
Transposing a Long String | Excel Worksheet Functions | |||
converting a string to long | Excel Programming |